Page 1 of 1

Tile deconstruction and blueprinting

Posted: Mon May 01, 2017 5:50 pm
by mickael9
It's currently not possible to ask for the deconstruction of specific tiles (or just tiles in an area).
It's also not possible to create a blueprint using LuaItemStack::create_blueprint with only tiles or to refuse to create the blueprint if only tiles are found

Proposal:
  • Add LuaTile::order_deconstruction(force)
  • Add LuaTile::cancel_deconstruction(force)
  • Add LuaTile::to_be_deconstructed()
  • Change LuaSurface::(cancel_)deconstruct_area and LuaItemStack::create_blueprint:
    1. Add always_include_tiles to LuaSurface::(cancel_)deconstruct_area
    2. Add exclude_entities: if true, entities are not included in the blueprint/deconstruct
    3. Add exclude_tiles: similar to exclude_entities but for tiles, ignored if always_include_tiles is true because that would be confusing

Re: Tile deconstruction and blueprinting

Posted: Mon May 01, 2017 7:35 pm
by Rseding91
For the tile related deconstruction/cancel deconstruction: that's done by checking if their exists a deconstructable tile proxy entity at that tile position.

As for the other ones: you can just check that the blueprint.tiles has/doesn't have something and clear it yourself through the API.

Re: Tile deconstruction and blueprinting

Posted: Mon May 01, 2017 7:55 pm
by mickael9
Rseding91 wrote:For the tile related deconstruction/cancel deconstruction: that's done by checking if their exists a deconstructable tile proxy entity at that tile position.
And how would you do that exactly? find_entity doesn't return them. This is what I tried:

Code: Select all

print(game.player.surface.find_entity('deconstructible-tile-proxy', game.player.position)) -- nil (player standing on concrete)
How about just adding always_include_tiles to deconstruct_area() ? (we can always cancel deconstruction on things we don't want deconstructed)

Re: Tile deconstruction and blueprinting

Posted: Mon May 01, 2017 9:30 pm
by Nexela
You have to create the proxy with surface.create_entity at the positions of the tile you want to deconstruct (I think)
\

Re: Tile deconstruction and blueprinting

Posted: Mon May 01, 2017 9:34 pm
by Rseding91
mickael9 wrote:
Rseding91 wrote:For the tile related deconstruction/cancel deconstruction: that's done by checking if their exists a deconstructable tile proxy entity at that tile position.
And how would you do that exactly? find_entity doesn't return them. This is what I tried:

Code: Select all

print(game.player.surface.find_entity('deconstructible-tile-proxy', game.player.position)) -- nil (player standing on concrete)
How about just adding always_include_tiles to deconstruct_area() ? (we can always cancel deconstruction on things we don't want deconstructed)
find_entity takes an absolute position - which it's extremely unlikely you're standing on the exact spot of the proxy entity.

Use find_entities_filtered and give it a bounding box.