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.
LuaSurface::deconstruct_area gets filter parameter or...
- Omnifarious
- Filter Inserter
- Posts: 279
- Joined: Wed Jul 26, 2017 3:24 pm
- Contact:
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: LuaSurface::deconstruct_area gets filter parameter or...
I'd prefer a table of names/types. At least that can be stored in lua.Omnifarious wrote:To this end, the existing LuaSurface::deconstruct_area function should get an optional filter parameter that must be a deconstruction planner...
- Omnifarious
- Filter Inserter
- Posts: 279
- Joined: Wed Jul 26, 2017 3:24 pm
- Contact:
Re: LuaSurface::deconstruct_area gets filter parameter or...
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.eradicator wrote:I'd prefer a table of names/types. At least that can be stored in lua.Omnifarious wrote:To this end, the existing LuaSurface::deconstruct_area function should get an optional filter parameter that must be a deconstruction planner...
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.
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: LuaSurface::deconstruct_area gets filter parameter or...
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.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.
Re: LuaSurface::deconstruct_area gets filter parameter or...
Ok, I added this for 0.17.
If you want to get ahold of me I'm almost always on Discord.