From b92beebda78561c8ec65cd054399674e4ffcbdbf Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Tue, 24 Oct 2023 18:24:07 +0900 Subject: [PATCH 1/4] two command --- config/_file_loader.lua | 1 + config/expcore/roles.lua | 4 +++- modules/commands/surface-clearing.lua | 34 +++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 modules/commands/surface-clearing.lua diff --git a/config/_file_loader.lua b/config/_file_loader.lua index 16ec66d8..aa1853cf 100644 --- a/config/_file_loader.lua +++ b/config/_file_loader.lua @@ -44,6 +44,7 @@ return { 'modules.commands.vlayer', 'modules.commands.enemy', 'modules.commands.waterfill', + 'modules.commands.surface-clearing', --- Addons 'modules.addons.chat-popups', diff --git a/config/expcore/roles.lua b/config/expcore/roles.lua index 42d31c34..b8a27f3b 100644 --- a/config/expcore/roles.lua +++ b/config/expcore/roles.lua @@ -230,7 +230,9 @@ Roles.new_role('Member','Mem') 'command/auto-research', 'command/manual-train', 'command/lawnmower', - 'command/waterfill' + 'command/waterfill', + 'command/clear-item-on-ground', + 'command/clear-blueprint' } local hours3, hours15 = 3*216000, 15*60 diff --git a/modules/commands/surface-clearing.lua b/modules/commands/surface-clearing.lua new file mode 100644 index 00000000..d8cb19ef --- /dev/null +++ b/modules/commands/surface-clearing.lua @@ -0,0 +1,34 @@ +--[[-- Commands Module - Clear Item On Ground + - Adds a command that clear item on ground so blueprint can deploy safely + @commands Clear Item On Ground +]] + +local Commands = require 'expcore.commands' --- @dep expcore.commands +require 'config.expcore.command_general_parse' + +Commands.new_command('clear-item-on-ground', 'Clear Item On Ground') +:add_param('range', false, 'integer-range', 1, 1000) +:register(function(player, range) + for _, e in pairs(player.surface.find_entities_filtered{position=player.position, radius=range, name='item-on-ground'}) do + if e.stack then + e.stack.clear() + end + end + + return Commands.success +end) + +--[[-- Commands Module - Clear Blueprint + - Adds a command that clear blueprint spamming or leftover + @commands Clear Blueprint +]] + +Commands.new_command('clear-blueprint', 'Clear Blueprint') +:add_param('range', false, 'integer-range', 1, 1000) +:register(function(player, range) + for _, e in pairs(player.surface.find_entities_filtered{position=player.position, radius=range, type='entity-ghost'}) do + e.destroy() + end + + return Commands.success +end) \ No newline at end of file From f64c936c9351b5882760ca20f039e20725179549 Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Tue, 24 Oct 2023 21:00:39 +0900 Subject: [PATCH 2/4] . --- modules/commands/surface-clearing.lua | 5 ----- 1 file changed, 5 deletions(-) diff --git a/modules/commands/surface-clearing.lua b/modules/commands/surface-clearing.lua index d8cb19ef..48f38750 100644 --- a/modules/commands/surface-clearing.lua +++ b/modules/commands/surface-clearing.lua @@ -18,11 +18,6 @@ Commands.new_command('clear-item-on-ground', 'Clear Item On Ground') return Commands.success end) ---[[-- Commands Module - Clear Blueprint - - Adds a command that clear blueprint spamming or leftover - @commands Clear Blueprint -]] - Commands.new_command('clear-blueprint', 'Clear Blueprint') :add_param('range', false, 'integer-range', 1, 1000) :register(function(player, range) From 73fc64782397fabe5a4c56c0debf355708b5c5bf Mon Sep 17 00:00:00 2001 From: Cooldude2606 <25043174+Cooldude2606@users.noreply.github.com> Date: Thu, 21 Dec 2023 21:29:58 +0000 Subject: [PATCH 3/4] Items are moved to spawn chests on clear --- modules/commands/surface-clearing.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/commands/surface-clearing.lua b/modules/commands/surface-clearing.lua index 48f38750..99e4254a 100644 --- a/modules/commands/surface-clearing.lua +++ b/modules/commands/surface-clearing.lua @@ -3,6 +3,7 @@ @commands Clear Item On Ground ]] +local copy_items_stack = _C.copy_items_stack --- @dep expcore.common local Commands = require 'expcore.commands' --- @dep expcore.commands require 'config.expcore.command_general_parse' @@ -11,6 +12,9 @@ Commands.new_command('clear-item-on-ground', 'Clear Item On Ground') :register(function(player, range) for _, e in pairs(player.surface.find_entities_filtered{position=player.position, radius=range, name='item-on-ground'}) do if e.stack then + -- calling move_items_stack(e.stack) will crash to desktop + -- https://forums.factorio.com/viewtopic.php?f=7&t=110322 + copy_items_stack{e.stack} e.stack.clear() end end From ab53c0d8eed2cd98af15d2ea5bad1f28c883b969 Mon Sep 17 00:00:00 2001 From: Cooldude2606 <25043174+Cooldude2606@users.noreply.github.com> Date: Thu, 21 Dec 2023 21:35:12 +0000 Subject: [PATCH 4/4] Fix missing comma from merge conflict --- config/expcore/roles.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/expcore/roles.lua b/config/expcore/roles.lua index a1d8ecdb..416e9f2d 100644 --- a/config/expcore/roles.lua +++ b/config/expcore/roles.lua @@ -232,7 +232,7 @@ Roles.new_role('Member','Mem') 'command/lawnmower', 'command/waterfill', 'command/clear-item-on-ground', - 'command/clear-blueprint' + 'command/clear-blueprint', 'gui/surveillance' }