From 1d8e31590010c47bd5f505170e6a27635da6e5d1 Mon Sep 17 00:00:00 2001 From: Matthew Heguy Date: Wed, 23 Jan 2019 18:34:29 -0500 Subject: [PATCH 1/2] Add revive ghosts --- features/admin_commands.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/features/admin_commands.lua b/features/admin_commands.lua index cb6f092c..fe67e8ff 100644 --- a/features/admin_commands.lua +++ b/features/admin_commands.lua @@ -241,6 +241,19 @@ local function teleport_command(args, player) end end +--- Revives ghosts around the player +local function revive_ghosts(args, player) + local radius = args.radius + local pos = player.position + for _, e in pairs(player.surface.find_entities_filtered {area = {{pos.x - radius, pos.y - radius}, {pos.x + radius, pos.y + radius}}}) do + if e.type == 'entity-ghost' then + e.revive() + else + e.health = 10000 + end + end +end + -- Event registrations Event.add(defines.events.on_built_entity, built_entity) @@ -376,3 +389,14 @@ Command.add( }, teleport_command ) + +Command.add( + 'revive-ghosts', + { + description = 'Revives the ghosts within the provided radius around you', + arguments = {'radius'}, + default_values = {radius = 10}, + admin_only = true + }, + revive_ghosts +) From 1ce121d4c75e740c680304eaa75ffa13781bf2fd Mon Sep 17 00:00:00 2001 From: Matthew Heguy Date: Wed, 30 Jan 2019 19:38:43 -0500 Subject: [PATCH 2/2] Ignore non-ghosts --- features/admin_commands.lua | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/features/admin_commands.lua b/features/admin_commands.lua index fe67e8ff..9e239174 100644 --- a/features/admin_commands.lua +++ b/features/admin_commands.lua @@ -245,12 +245,8 @@ end local function revive_ghosts(args, player) local radius = args.radius local pos = player.position - for _, e in pairs(player.surface.find_entities_filtered {area = {{pos.x - radius, pos.y - radius}, {pos.x + radius, pos.y + radius}}}) do - if e.type == 'entity-ghost' then - e.revive() - else - e.health = 10000 - end + for _, e in pairs(player.surface.find_entities_filtered {area = {{pos.x - radius, pos.y - radius}, {pos.x + radius, pos.y + radius}}, type = 'entity-ghost'}) do + e.revive() end end