Add method to deconstruct tiles under entities

Things that already exist in the current mod API
Post Reply
d3x0r
Filter Inserter
Filter Inserter
Posts: 316
Joined: Sun Jun 04, 2017 8:56 am
Contact:

Add method to deconstruct tiles under entities

Post by d3x0r »

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

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2919
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: Add method to deconstruct tiles under entities

Post by Optera »

Can't you set the deconstructor to tiles only through the API?
If not that could easily be added and since we can set deconstructors to tile only in game.

d3x0r
Filter Inserter
Filter Inserter
Posts: 316
Joined: Sun Jun 04, 2017 8:56 am
Contact:

Re: Add method to deconstruct tiles under entities

Post by d3x0r »

Optera wrote:Can't you set the deconstructor to tiles only through the API?
If not that could easily be added and since we can set deconstructors to tile only in game.
Probably; but I couldn't figure out how to trigger the deconstructor in the hand stack.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13219
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Add method to deconstruct tiles under entities

Post by Rseding91 »

surface.create_entity{name="deconstructible-tile-proxy", position=tile.position, force = force}
That is the supported way to deconstruct tiles. It's exactly what the game does when you mark tiles with the deconstruction planner.
If you want to get ahold of me I'm almost always on Discord.

d3x0r
Filter Inserter
Filter Inserter
Posts: 316
Joined: Sun Jun 04, 2017 8:56 am
Contact:

Re: Add method to deconstruct tiles under entities

Post by d3x0r »

Yes, that is fairly simple; but undocumented.
Also not obvious how you would cancel deconstruction.

would be nice as a convenience if there was just a simple extension to LuaTile that did that single line.

Not pushin the issue; just sayin....

Post Reply

Return to “Already exists”