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

Merge pull request #182 from JCA122204/patch-1

Remove unessecary lines (more)
This commit is contained in:
Valansch 2018-06-05 11:26:16 +02:00 committed by GitHub
commit bdbead938e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 64 deletions

View File

@ -51,9 +51,7 @@ local function player_joined_game(event)
spawn_name = get_min_count_spawn_name() spawn_name = get_min_count_spawn_name()
if not spawn_name then if not spawn_name then return end
return
end
local spawn = global.spawns[spawn_name] local spawn = global.spawns[spawn_name]
global.player_spawns[index] = 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_name = global.player_spawns[index]
local spawn = global.spawns[spawn_name] local spawn = global.spawns[spawn_name]
if not spawn then if not spawn then return end
return
end
local count = spawn.count local count = spawn.count
spawn.count = count - 1 spawn.count = count - 1
@ -81,9 +77,7 @@ local function player_respawned(event)
local spawn_name = global.player_spawns[index] local spawn_name = global.player_spawns[index]
local spawn = global.spawns[spawn_name] local spawn = global.spawns[spawn_name]
if not spawn then if not spawn then return end
return
end
game.players[index].teleport(spawn) game.players[index].teleport(spawn)
end end
@ -143,10 +137,8 @@ end
local function print_spawns() local function print_spawns()
local str = "" local str = ""
for name, spawn in pairs(global.spawns) do for name, spawn in pairs(global.spawns) do
str = str .. name .. ": (" .. spawn.x .. ", " .. spawn.y .. "), player count = " .. spawn.count .. "\n\r" game.player.print(string.format("%s: (%d, %d), player count = %d", name, spawn.x, spawn.y, spawn.count))
end end
game.player.print(str)
end end
local function print_players_for_spawn(target_spawn_name) local function print_players_for_spawn(target_spawn_name)
@ -166,9 +158,7 @@ local function print_players_for_spawn(target_spawn_name)
end end
end end
if str == "" then if str == "" then str = "no players" end
str = "no players"
end
game.player.print(str) game.player.print(str)
end end
@ -189,11 +179,7 @@ local function tp_spawn_command(cmd)
table.insert( ps,p ) table.insert( ps,p )
end end
if #ps == 1 then if #ps == 1 then tp_spawn(game.player.name, ps[1]) else tp_spawn(ps[1], ps[2]) end
tp_spawn(game.player.name, ps[1])
else
tp_spawn(ps[1], ps[2])
end
end end
function change_spawn_command(cmd) function change_spawn_command(cmd)
@ -209,9 +195,7 @@ function change_spawn_command(cmd)
end end
local ps ={} local ps ={}
for p in params:gmatch("%S+") do for p in params:gmatch("%S+") do table.insert( ps,p ) end
table.insert( ps,p )
end
change_spawn(ps[1], ps[2]) change_spawn(ps[1], ps[2])
end end
@ -238,9 +222,7 @@ local function print_players_for_spawn_command(cmd)
end end
local ps ={} local ps ={}
for p in params:gmatch("%S+") do for p in params:gmatch("%S+") do table.insert( ps,p ) end
table.insert( ps,p )
end
print_players_for_spawn(ps[1]) print_players_for_spawn(ps[1])
end end
@ -252,4 +234,4 @@ Event.add(defines.events.on_player_respawned, player_respawned)
commands.add_command("tpspawn", "<player> <spawn_name> teleports a player to the spawn point (Admins only)", tp_spawn_command) commands.add_command("tpspawn", "<player> <spawn_name> teleports a player to the spawn point (Admins only)", tp_spawn_command)
commands.add_command("changespawn", "<player> <spawn_name> changes the spawn point for a player (Admins only)", change_spawn_command) commands.add_command("changespawn", "<player> <spawn_name> 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("printspawns", "prints info on all spawn points (Admins only)", print_spawns_command)
commands.add_command("printplayersforspawn", "<spawn_name> prints all the connected players for a spawn (Admins only)", print_players_for_spawn_command) commands.add_command("printplayersforspawn", "<spawn_name> prints all the connected players for a spawn (Admins only)", print_players_for_spawn_command)

View File

@ -87,14 +87,11 @@ local function tasklist(player)
global.tasklist_items[3] = frame.textfield_task_3.text global.tasklist_items[3] = frame.textfield_task_3.text
global.tasklist_items[4] = frame.textfield_task_4.text global.tasklist_items[4] = frame.textfield_task_4.text
global.tasklist_items[5] = frame.textfield_task_5.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 if (global.tasklist_items[5] .. global.tasklist_items[4] .. global.tasklist_items[3] .. global.tasklist_items[2] .. global.tasklist_items[1] == "") then return end
return
end
global.tasklist_author = player.name global.tasklist_author = player.name
local msg = player.name local msg = player.name .. " has created an updated tasklist!"
msg = msg .. " has created an updated tasklist!"
local frame = player.gui.left["tasklist-assembler"] local frame = player.gui.left["tasklist-assembler"]
frame.destroy() frame.destroy()
@ -103,14 +100,9 @@ local function tasklist(player)
local frame = player.gui.left["tasklist-panel"] local frame = player.gui.left["tasklist-panel"]
if (frame) then if (frame) then frame.destroy() end
frame.destroy()
end
if (global.autoshow_tasklist_for_player[player.name] == true) then
tasklist_show(player)
end
if (global.autoshow_tasklist_for_player[player.name] == true) then tasklist_show(player) end
end end
game.print(msg) game.print(msg)
@ -161,45 +153,27 @@ local function on_gui_click(event)
if (name == "tasklist") then if (name == "tasklist") then
local frame = player.gui.left["tasklist-panel"] local frame = player.gui.left["tasklist-panel"]
if (frame) then if (frame) then frame.destroy() else tasklist_show(player) end
frame.destroy()
else
tasklist_show(player)
end
local frame = player.gui.left["tasklist-assembler"] local frame = player.gui.left["tasklist-assembler"]
if (frame) then if (frame) then frame.destroy() end
frame.destroy()
end
end end
if (name == "new_tasklist_assembler_button") then if (name == "new_tasklist_assembler_button") then
local frame = player.gui.left["tasklist-assembler"] local frame = player.gui.left["tasklist-assembler"]
if (frame) then if (frame) then frame.destroy() else tasklist_assembler(player) end
frame.destroy()
else
tasklist_assembler(player)
end
end end
if (name == "create_new_tasklist_button") then if (name == "create_new_tasklist_button") then tasklist(player) end
tasklist(player)
end
if (name == "tasklist_hide_button") then if (name == "tasklist_hide_button") then
local frame = player.gui.left["tasklist-panel"] local frame = player.gui.left["tasklist-panel"]
if (frame) then if (frame) then frame.destroy() end
frame.destroy()
end
local frame = player.gui.left["tasklist-assembler"] local frame = player.gui.left["tasklist-assembler"]
if (frame) then if (frame) then frame.destroy() end
frame.destroy()
end
end end
if (name == "auto_show_tasklist_checkbox") then if (name == "auto_show_tasklist_checkbox") then global.autoshow_tasklist_for_player[player.name] = event.element.state end
global.autoshow_tasklist_for_player[player.name] = event.element.state
end
end end
Event.add(defines.events.on_gui_click, on_gui_click) Event.add(defines.events.on_gui_click, on_gui_click)