LuaSurface::deconstruct_area gets filter parameter or...

User avatar
Omnifarious
Filter Inserter
Filter Inserter
Posts: 279
Joined: Wed Jul 26, 2017 3:24 pm
Contact:

LuaSurface::deconstruct_area gets filter parameter or...

Post 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.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

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

Post 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.
User avatar
Omnifarious
Filter Inserter
Filter Inserter
Posts: 279
Joined: Wed Jul 26, 2017 3:24 pm
Contact:

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

Post 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.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

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

Post 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.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14931
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post by Rseding91 »

Ok, I added this for 0.17.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Implemented mod requests”