Page 1 of 1

LuaSurface::deconstruct_area gets filter parameter or...

Posted: Wed Jun 13, 2018 4:43 pm
by Omnifarious
LuaSurface::deconstruct_area should get filter parameter or LuaItemStack should get deconstruct_area function.

The deconstruction planner with its entity filters is a really useful tool. It would be nice to use that tool in scripts rather than having to reinvent it by manually scanning a surface and applying our own filter code.

To this end, the existing LuaSurface::deconstruct_area function should get an optional filter parameter that must be a deconstruction planner, and if it gets one it applies the item filter in that planner. Alternatively, LuaItemStack can get a deconstruct_area function akin to the already existing build_blueprint function that will act similarly when it's called for a non-deconstruction planner items as build_blueprint acts when called on a non-blueprint items.

For completeness, perhaps LuaSurface::cancel_deconstruct_area should get the same treatment, though it's less useful as you can just blanket cancel everything, then deconstruct again with a different filter.

Re: LuaSurface::deconstruct_area gets filter parameter or...

Posted: Wed Jun 13, 2018 4:50 pm
by eradicator
Omnifarious wrote:To this end, the existing LuaSurface::deconstruct_area function should get an optional filter parameter that must be a deconstruction planner...
I'd prefer a table of names/types. At least that can be stored in lua.

Re: LuaSurface::deconstruct_area gets filter parameter or...

Posted: Wed Jun 13, 2018 8:15 pm
by Omnifarious
eradicator wrote:
Omnifarious wrote:To this end, the existing LuaSurface::deconstruct_area function should get an optional filter parameter that must be a deconstruction planner...
I'd prefer a table of names/types. At least that can be stored in lua.
My specific use-case was modifying the recursive blueprints mod to allow deconstruction by putting in a deconstruction planner. And I wanted to filter the deconstruction.

I believe it's not too hard to get that table out of the deconstruction planner though. Maybe instead code should be added to the deconstruction planner to allow you to easily retrieve a filter table that can be fed into the deconstruct function on LuaSurface.

Re: LuaSurface::deconstruct_area gets filter parameter or...

Posted: Wed Jun 13, 2018 8:32 pm
by eradicator
Omnifarious wrote: Maybe instead code should be added to the deconstruction planner to allow you to easily retrieve a filter table that can be fed into the deconstruct function on LuaSurface.
The table for that is already there LuaItemStack.entity_filters. So there just needs to be an option to plug it directly into deconstruct_area.

Re: LuaSurface::deconstruct_area gets filter parameter or...

Posted: Fri Jun 15, 2018 4:15 pm
by Rseding91
Ok, I added this for 0.17.