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
2 months ago
0.15 - 2.0
22.6K
Environment

g Factorio 2.0 compatibility

2 months ago
(updated 2 months ago)

I think the only change needed for compatibility with Factorio 2.0 is the renaming of created_entity to entity in the event object for the on_built_entity and the on_robot_built_entity events.

I have tested the following control.lua for both manually placed objects and objects placed by robots:

--[[get dir of decorations under entities]]
script.on_event(defines.events.on_built_entity, 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.on_robot_built_entity, 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_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)

Works flawlessly so far.

2 months ago

I appreciate your help, we can all enjoy the mod now.

2 months ago
(updated 2 months ago)

You guys are faster than I can get a decent break at my work. :)

(update should be released)

2 months ago

Thank you!

New response