Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lawnmower #311

Merged
merged 14 commits into from
Sep 1, 2024
2 changes: 1 addition & 1 deletion config/_file_loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ return {
'modules.commands.pollution',
'modules.commands.train',
'modules.commands.friendly-fire',
'modules.commands.lawnmower',
'modules.commands.research',
'modules.commands.vlayer',
'modules.commands.enemy',
Expand Down Expand Up @@ -67,6 +66,7 @@ return {
'modules.addons.nukeprotect',
'modules.addons.inserter',
'modules.addons.miner',
'modules.addons.lawnmower',
'modules.addons.logging',

-- Control
Expand Down
6 changes: 6 additions & 0 deletions config/lawnmower.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
--- Settings for lawnmower
-- @config lawnmower

return {
destroy_decoratives = false
}
30 changes: 28 additions & 2 deletions modules/commands/lawnmower.lua → modules/addons/lawnmower.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
--[[-- Commands Module - Lawnmower
--[[-- Addon Lawnmower
- Adds a command that clean up biter corpse and nuclear hole
@commands Lawnmower
@addon Lawnmower
]]

local Commands = require 'expcore.commands' --- @dep expcore.commands
local Event = require 'utils.event' --- @dep utils.event
local config = require 'config.lawnmower' --- @dep config.lawnmower
require 'config.expcore.command_general_parse'

Commands.new_command('lawnmower', 'Clean up biter corpse, decoratives and nuclear hole')
Expand Down Expand Up @@ -31,3 +33,27 @@ Commands.new_command('lawnmower', 'Clean up biter corpse, decoratives and nuclea

return Commands.success
end)

local function destroy_decoratives(entity)
if entity.type ~= 'entity-ghost' and entity.type ~= 'tile-ghost' and entity.prototype.selectable_in_game then
entity.surface.destroy_decoratives{area=entity.selection_box}
end
end

if config.destroy_decoratives then
Event.add(defines.events.on_built_entity, function(event)
destroy_decoratives(event.created_entity)
end)

Event.add(defines.events.on_robot_built_entity, function(event)
destroy_decoratives(event.created_entity)
end)

Event.add(defines.events.script_raised_built, function(event)
destroy_decoratives(event.entity)
end)

Event.add(defines.events.script_raised_revive, function(event)
destroy_decoratives(event.entity)
end)
end
Loading