Add method to deconstruct tiles under entities
Posted: Wed Aug 09, 2017 5:15 am
TL;DR - Please add order_deconstruct and cancel_deconstruction as from LuaEntity to LuaTile.
Alternative (additionally) surface.deconstruct_area_tiles{}
Edit: I did find a workaround with help from discord; create a new force that's player-friendly and assign entities in the selected area to the other force, and return them to original force when done.
Edit2: a second suggestion that works and is easier
surface.create_entity{name="deconstructible-tile-proxy", position=tile.position, force = force}
While trying to support replacing tiles via bots, I ran into an issue.
My selection tool has selection_mode = {"blueprint"} and always_include_tiles = true. So on on_player_selected_area, I get the tiles selected, and at the moment I'm only interested in the tiles...
Each LuaTile has a position, which I can compute an area and use surface.deconstruct_area; but if there are entities on the tiles, that deconstruct command only deconstructs the entities, and not the tiles under them.
I tried to catch on_marked_for_deconstruction to cancel entities that were not tiles, but then nothing happens; because, again, only the top layer gets the deconstruction.
I tried to get clever and do two surface.deconstruct_areas hoping it would ignore the entities already marked for deconstruction, but it didn't help.
This is a demo using the builtin deconstruct tools and blueprint tools to replace just the tiles under entities (accumulators in this case)
https://youtu.be/U7xfq6fqJC4
Current source of mod (creates 2 entities that look a lot alike, the second one is my selection tool, the sorted-deconstructor-2 is a attempt to extend deconstruction planner, otherwise I couldn't figure a way to right click on an item and show a gui )
https://github.com/d3x0r/factorio-sorted-deconstruct
it's mod name should be sorted-blueprint-and-deconstruct_0.1.0
Alternative (additionally) surface.deconstruct_area_tiles{}
Edit: I did find a workaround with help from discord; create a new force that's player-friendly and assign entities in the selected area to the other force, and return them to original force when done.
Edit2: a second suggestion that works and is easier
surface.create_entity{name="deconstructible-tile-proxy", position=tile.position, force = force}
While trying to support replacing tiles via bots, I ran into an issue.
My selection tool has selection_mode = {"blueprint"} and always_include_tiles = true. So on on_player_selected_area, I get the tiles selected, and at the moment I'm only interested in the tiles...
Each LuaTile has a position, which I can compute an area and use surface.deconstruct_area; but if there are entities on the tiles, that deconstruct command only deconstructs the entities, and not the tiles under them.
I tried to catch on_marked_for_deconstruction to cancel entities that were not tiles, but then nothing happens; because, again, only the top layer gets the deconstruction.
I tried to get clever and do two surface.deconstruct_areas hoping it would ignore the entities already marked for deconstruction, but it didn't help.
This is a demo using the builtin deconstruct tools and blueprint tools to replace just the tiles under entities (accumulators in this case)
https://youtu.be/U7xfq6fqJC4
Current source of mod (creates 2 entities that look a lot alike, the second one is my selection tool, the sorted-deconstructor-2 is a attempt to extend deconstruction planner, otherwise I couldn't figure a way to right click on an item and show a gui )
https://github.com/d3x0r/factorio-sorted-deconstruct
it's mod name should be sorted-blueprint-and-deconstruct_0.1.0