From ba5b28657e0a86453737d739fc6c1fda0f5f7a28 Mon Sep 17 00:00:00 2001 From: JCA122204 <34488805+JCA122204@users.noreply.github.com> Date: Mon, 4 Jun 2018 18:35:17 -0400 Subject: [PATCH 1/3] Remove unessecary lines --- tasklist.lua | 48 +++++++++++------------------------------------- 1 file changed, 11 insertions(+), 37 deletions(-) diff --git a/tasklist.lua b/tasklist.lua index c675ed75..45c8ad4b 100644 --- a/tasklist.lua +++ b/tasklist.lua @@ -87,14 +87,11 @@ local function tasklist(player) global.tasklist_items[3] = frame.textfield_task_3.text global.tasklist_items[4] = frame.textfield_task_4.text global.tasklist_items[5] = frame.textfield_task_5.text - if (global.tasklist_items[5] .. global.tasklist_items[4] .. global.tasklist_items[3] .. global.tasklist_items[2] .. global.tasklist_items[1] == "") then - return - end + if (global.tasklist_items[5] .. global.tasklist_items[4] .. global.tasklist_items[3] .. global.tasklist_items[2] .. global.tasklist_items[1] == "") then return end global.tasklist_author = player.name - local msg = player.name - msg = msg .. " has created an updated tasklist!" + local msg = player.name .. " has created an updated tasklist!" local frame = player.gui.left["tasklist-assembler"] frame.destroy() @@ -103,14 +100,9 @@ local function tasklist(player) local frame = player.gui.left["tasklist-panel"] - if (frame) then - frame.destroy() - end - - if (global.autoshow_tasklist_for_player[player.name] == true) then - tasklist_show(player) - end + if (frame) then frame.destroy() end + if (global.autoshow_tasklist_for_player[player.name] == true) then tasklist_show(player) end end game.print(msg) @@ -161,45 +153,27 @@ local function on_gui_click(event) if (name == "tasklist") then local frame = player.gui.left["tasklist-panel"] - if (frame) then - frame.destroy() - else - tasklist_show(player) - end + if (frame) then frame.destroy() else tasklist_show(player) end local frame = player.gui.left["tasklist-assembler"] - if (frame) then - frame.destroy() - end + if (frame) then frame.destroy() end end if (name == "new_tasklist_assembler_button") then local frame = player.gui.left["tasklist-assembler"] - if (frame) then - frame.destroy() - else - tasklist_assembler(player) - end + if (frame) then frame.destroy() else tasklist_assembler(player) end end - if (name == "create_new_tasklist_button") then - tasklist(player) - end + if (name == "create_new_tasklist_button") then tasklist(player) end if (name == "tasklist_hide_button") then local frame = player.gui.left["tasklist-panel"] - if (frame) then - frame.destroy() - end + if (frame) then frame.destroy() end local frame = player.gui.left["tasklist-assembler"] - if (frame) then - frame.destroy() - end + if (frame) then frame.destroy() end end - if (name == "auto_show_tasklist_checkbox") then - global.autoshow_tasklist_for_player[player.name] = event.element.state - end + if (name == "auto_show_tasklist_checkbox") then global.autoshow_tasklist_for_player[player.name] = event.element.state end end Event.add(defines.events.on_gui_click, on_gui_click) From 23fbc50801783671339f28668479ef35718202d1 Mon Sep 17 00:00:00 2001 From: JCA122204 <34488805+JCA122204@users.noreply.github.com> Date: Mon, 4 Jun 2018 18:40:17 -0400 Subject: [PATCH 2/3] Remove unessecary lines --- spawn_control.lua | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/spawn_control.lua b/spawn_control.lua index b7694c8b..10dcda6f 100644 --- a/spawn_control.lua +++ b/spawn_control.lua @@ -51,9 +51,7 @@ local function player_joined_game(event) spawn_name = get_min_count_spawn_name() - if not spawn_name then - return - end + if not spawn_name then return end local spawn = global.spawns[spawn_name] global.player_spawns[index] = spawn_name @@ -68,9 +66,7 @@ local function player_left_game(event) local spawn_name = global.player_spawns[index] local spawn = global.spawns[spawn_name] - if not spawn then - return - end + if not spawn then return end local count = spawn.count spawn.count = count - 1 @@ -81,9 +77,7 @@ local function player_respawned(event) local spawn_name = global.player_spawns[index] local spawn = global.spawns[spawn_name] - if not spawn then - return - end + if not spawn then return end game.players[index].teleport(spawn) end @@ -142,9 +136,7 @@ end local function print_spawns() local str = "" - for name, spawn in pairs(global.spawns) do - str = str .. name .. ": (" .. spawn.x .. ", " .. spawn.y .. "), player count = " .. spawn.count .. "\n\r" - end + for name, spawn in pairs(global.spawns) do str = str .. name .. ": (" .. spawn.x .. ", " .. spawn.y .. "), player count = " .. spawn.count .. "\n\r" end game.player.print(str) end @@ -166,9 +158,7 @@ local function print_players_for_spawn(target_spawn_name) end end - if str == "" then - str = "no players" - end + if str == "" then str = "no players" end game.player.print(str) end @@ -189,11 +179,7 @@ local function tp_spawn_command(cmd) table.insert( ps,p ) end - if #ps == 1 then - tp_spawn(game.player.name, ps[1]) - else - tp_spawn(ps[1], ps[2]) - end + if #ps == 1 then tp_spawn(game.player.name, ps[1]) else tp_spawn(ps[1], ps[2]) end end function change_spawn_command(cmd) @@ -209,9 +195,7 @@ function change_spawn_command(cmd) end local ps ={} - for p in params:gmatch("%S+") do - table.insert( ps,p ) - end + for p in params:gmatch("%S+") do table.insert( ps,p ) end change_spawn(ps[1], ps[2]) end @@ -238,9 +222,7 @@ local function print_players_for_spawn_command(cmd) end local ps ={} - for p in params:gmatch("%S+") do - table.insert( ps,p ) - end + for p in params:gmatch("%S+") do table.insert( ps,p ) end print_players_for_spawn(ps[1]) end @@ -252,4 +234,4 @@ Event.add(defines.events.on_player_respawned, player_respawned) commands.add_command("tpspawn", " teleports a player to the spawn point (Admins only)", tp_spawn_command) commands.add_command("changespawn", " changes the spawn point for a player (Admins only)", change_spawn_command) commands.add_command("printspawns", "prints info on all spawn points (Admins only)", print_spawns_command) -commands.add_command("printplayersforspawn", " prints all the connected players for a spawn (Admins only)", print_players_for_spawn_command) \ No newline at end of file +commands.add_command("printplayersforspawn", " prints all the connected players for a spawn (Admins only)", print_players_for_spawn_command) From 0bd88cc924d8f2fbf29b2c4bb7b08688d8448dc3 Mon Sep 17 00:00:00 2001 From: Valansch Date: Tue, 5 Jun 2018 11:25:00 +0200 Subject: [PATCH 3/3] Fixed bug in print_spawns and minor refactoring --- spawn_control.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spawn_control.lua b/spawn_control.lua index 10dcda6f..96c4e609 100644 --- a/spawn_control.lua +++ b/spawn_control.lua @@ -136,9 +136,9 @@ end local function print_spawns() local str = "" - for name, spawn in pairs(global.spawns) do str = str .. name .. ": (" .. spawn.x .. ", " .. spawn.y .. "), player count = " .. spawn.count .. "\n\r" end - - game.player.print(str) + for name, spawn in pairs(global.spawns) do + game.player.print(string.format("%s: (%d, %d), player count = %d", name, spawn.x, spawn.y, spawn.count)) + end end local function print_players_for_spawn(target_spawn_name)