mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 03:25:23 +09:00
Automatic Lawnmower (#311)
* Create lawnmower.lua * Update _file_loader.lua * Delete modules/commands/lawnmower.lua * Update lawnmower.lua * Create lawnmower.lua * Update lawnmower.lua * Update _file_loader.lua * Update lawnmower.lua
This commit is contained in:
@@ -39,7 +39,6 @@ return {
|
|||||||
'modules.commands.pollution',
|
'modules.commands.pollution',
|
||||||
'modules.commands.train',
|
'modules.commands.train',
|
||||||
'modules.commands.friendly-fire',
|
'modules.commands.friendly-fire',
|
||||||
'modules.commands.lawnmower',
|
|
||||||
'modules.commands.research',
|
'modules.commands.research',
|
||||||
'modules.commands.vlayer',
|
'modules.commands.vlayer',
|
||||||
'modules.commands.enemy',
|
'modules.commands.enemy',
|
||||||
@@ -67,6 +66,7 @@ return {
|
|||||||
'modules.addons.nukeprotect',
|
'modules.addons.nukeprotect',
|
||||||
'modules.addons.inserter',
|
'modules.addons.inserter',
|
||||||
'modules.addons.miner',
|
'modules.addons.miner',
|
||||||
|
'modules.addons.lawnmower',
|
||||||
'modules.addons.logging',
|
'modules.addons.logging',
|
||||||
|
|
||||||
-- Control
|
-- Control
|
||||||
|
|||||||
6
config/lawnmower.lua
Normal file
6
config/lawnmower.lua
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
--- Settings for lawnmower
|
||||||
|
-- @config lawnmower
|
||||||
|
|
||||||
|
return {
|
||||||
|
destroy_decoratives = false
|
||||||
|
}
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
--[[-- Commands Module - Lawnmower
|
--[[-- Addon Lawnmower
|
||||||
- Adds a command that clean up biter corpse and nuclear hole
|
- Adds a command that clean up biter corpse and nuclear hole
|
||||||
@commands Lawnmower
|
@addon Lawnmower
|
||||||
]]
|
]]
|
||||||
|
|
||||||
local Commands = require 'expcore.commands' --- @dep expcore.commands
|
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'
|
require 'config.expcore.command_general_parse'
|
||||||
|
|
||||||
Commands.new_command('lawnmower', 'Clean up biter corpse, decoratives and nuclear hole')
|
Commands.new_command('lawnmower', 'Clean up biter corpse, decoratives and nuclear hole')
|
||||||
@@ -31,3 +33,27 @@ Commands.new_command('lawnmower', 'Clean up biter corpse, decoratives and nuclea
|
|||||||
|
|
||||||
return Commands.success
|
return Commands.success
|
||||||
end)
|
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
|
||||||
Reference in New Issue
Block a user