1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-01-30 04:30:58 +02:00

Swapped from while to for loops, removed local unneccary variables and refresh function. Whitespace style improvements.

This commit is contained in:
TWLTriston 2017-09-24 10:03:15 -04:00 committed by Valansch
parent 694cac1d06
commit 5d893fb093

View File

@ -34,10 +34,8 @@ local function tasklist_show(player)
tasklist_label.style.maximal_height = 165 tasklist_label.style.maximal_height = 165
tasklist_label.style.font = "default" tasklist_label.style.font = "default"
local y = 1
local counter = 0 local counter = 0
while (y < 6) do for y = 1, 5 do
if not (global.tasklist_items[y] == "") then if not (global.tasklist_items[y] == "") then
counter = counter + 1 counter = counter + 1
@ -50,7 +48,6 @@ local function tasklist_show(player)
tasklist_label.style.maximal_height = 165 tasklist_label.style.maximal_height = 165
tasklist_label.style.font = "default" tasklist_label.style.font = "default"
end end
y = y + 1
end end
if global.tasklist_author ~= nil then if global.tasklist_author ~= nil then
@ -62,7 +59,6 @@ local function tasklist_show(player)
tasklist_label.style.font = "default" tasklist_label.style.font = "default"
end end
frame.add { type = "table", name = "tasklist_panel_button_table", colspan = 3 } frame.add { type = "table", name = "tasklist_panel_button_table", colspan = 3 }
local tasklist_panel_button_table = frame.tasklist_panel_button_table local tasklist_panel_button_table = frame.tasklist_panel_button_table
@ -79,7 +75,7 @@ local function tasklist_show(player)
tasklist_panel_button_table.new_tasklist_assembler_button.style.minimal_height = 38 tasklist_panel_button_table.new_tasklist_assembler_button.style.minimal_height = 38
tasklist_panel_button_table.tasklist_hide_button.style.font = "default-bold" tasklist_panel_button_table.tasklist_hide_button.style.font = "default-bold"
tasklist_panel_button_table.tasklist_hide_button.style.minimal_height = 38 tasklist_panel_button_table.tasklist_hide_button.style.minimal_height = 38
-- tasklist_panel_button_table.add { type = "checkbox", caption = "Show Tasklist", state = global.autoshow_tasklist_for_player[player.name], name = "auto_show_tasklist_checkbox" } -- Possible for later preferences tasklist_panel_button_table.add { type = "checkbox", caption = "Show Tasklist", state = global.autoshow_tasklist_for_player[player.name], name = "auto_show_tasklist_checkbox" }
end end
local function tasklist(player) local function tasklist(player)
@ -104,11 +100,7 @@ local function tasklist(player)
local frame = player.gui.left["tasklist-assembler"] local frame = player.gui.left["tasklist-assembler"]
frame.destroy() frame.destroy()
local x = 1 for _,player in pairs(game.players) do
while (game.players[x] ~= nil) do
local player = game.players[x]
local frame = player.gui.left["tasklist-panel"] local frame = player.gui.left["tasklist-panel"]
@ -120,28 +112,9 @@ local function tasklist(player)
tasklist_show(player) tasklist_show(player)
end end
player.print(msg)
x = x + 1
end
end
local function tasklist_refresh()
local x = 1
while (game.players[x] ~= nil) do
local player = game.players[x]
if (player.gui.left["tasklist-panel"]) then
local frame = player.gui.left["tasklist-panel"]
frame = frame.tasklist_panel_table
end
x = x + 1
end end
game.print(msg)
end end
local function tasklist_assembler(player) local function tasklist_assembler(player)
@ -169,7 +142,6 @@ local function tasklist_assembler(player)
frame_table["textfield_task_5"].style.maximal_width = 450 frame_table["textfield_task_5"].style.maximal_width = 450
frame_table.add { type = "label", caption = "" } frame_table.add { type = "label", caption = "" }
frame_table.add { type = "button", name = "create_new_tasklist_button", caption = "Publish" } frame_table.add { type = "button", name = "create_new_tasklist_button", caption = "Publish" }
end end
function tasklist_sync_for_new_joining_player(event) function tasklist_sync_for_new_joining_player(event)
@ -186,7 +158,6 @@ function tasklist_sync_for_new_joining_player(event)
if (frame == nil) then if (frame == nil) then
tasklist_show(player) tasklist_show(player)
end end
end end
local function on_gui_click(event) local function on_gui_click(event)
@ -237,7 +208,6 @@ local function on_gui_click(event)
end end
end end
Event.register(defines.events.on_gui_click, on_gui_click) Event.register(defines.events.on_gui_click, on_gui_click)
Event.register(defines.events.on_player_joined_game, create_tasklist_gui) Event.register(defines.events.on_player_joined_game, create_tasklist_gui)
Event.register(defines.events.on_player_joined_game, tasklist_sync_for_new_joining_player) Event.register(defines.events.on_player_joined_game, tasklist_sync_for_new_joining_player)