Realistic Decoration Cleanup


Remove decorations prior to placing entities or tiles. In real life you would not build a house/road and leave the bushes below it, would you?

Tweaks
13 days ago
0.15 - 2.0
21.7K
Environment

g Small change to add SE compatibility

1 year, 1 month ago
(updated 1 year, 1 month ago)

The mod works great, but when used with Space Exploration it only removes decoration on Nauvis, while on other planets it does nothing. A small change to the indexes in control.lua can help with that. I've tested it for around ~20h on Nauvis, in space and one other planet and haven't found any problems with it.

Replace
 
game.surfaces[1]
 
with
 
game.surfaces[event.created_entity.surface_index]
 
in events.on_built_entity and events.on_robot_built_entity, and with
 
game.surfaces[event.entity.surface_index]
 
in events.script_raised_built and events.script_raised_revive:
 
 
 

--[[get dir of decorations under entities]]
script.on_event(defines.events.on_built_entity, function(event)
    if event.created_entity.type ~= "entity-ghost" and event.created_entity.type ~= "tile-ghost" and event.created_entity.prototype.selectable_in_game then
        game.surfaces[event.created_entity.surface_index].destroy_decoratives{area=event.created_entity.selection_box}
    end
end)

script.on_event(defines.events.on_robot_built_entity, function(event)
    if event.created_entity.type ~= "entity-ghost" and event.created_entity.type ~= "tile-ghost" and event.created_entity.prototype.selectable_in_game then
        game.surfaces[event.created_entity.surface_index].destroy_decoratives{area=event.created_entity.selection_box}
    end
end)

script.on_event(defines.events.script_raised_built, function(event)
    if event.entity.type ~= "entity-ghost" and event.entity.type ~= "tile-ghost" and event.entity.prototype.selectable_in_game then
        game.surfaces[event.entity.surface_index].destroy_decoratives{area=event.entity.selection_box}
    end
end)

script.on_event(defines.events.script_raised_revive, function(event)
    if event.entity.type ~= "entity-ghost" and event.entity.type ~= "tile-ghost" and event.entity.prototype.selectable_in_game then
        game.surfaces[event.entity.surface_index].destroy_decoratives{area=event.entity.selection_box}
    end
end)
1 year, 1 month ago

Can you upload modded file contents on pastebin?
Better to copy and paste the entire thing at once for me :)

1 year, 1 month ago

@MrSilver2510 This is the entire control.lua file, just copy my comment from --[[get dir of decorations to end) and paste it in your control.lua. :)

1 year, 1 month ago

My bad x)
Thank you!

10 months ago

Sorry, took a while. Should be fixed.

New response