Expose entity-ghost Inventory Filters to Lua

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
User avatar
_CodeGreen
Long Handed Inserter
Long Handed Inserter
Posts: 69
Joined: Sat Mar 05, 2022 11:30 am
Contact:

Expose entity-ghost Inventory Filters to Lua

Post by _CodeGreen »

Still working on Redo, and I'm running into the problem where I can't access the LuaInventory of a ghost container. Obviously it wouldn't be a good idea to expose the entire LuaInventory, you wouldn't want people inserting items in and out of them, but some parts of it (like `get_filter()` and more importantly set_filter()) would be really nice to have, if it's not too much trouble.

Example code works on normal entities but not ghost entities, data is the serialized entity properties.

Code: Select all

local inventory = entity.get_inventory(defines.inventory.chest)
for index, filter in pairs(data.inventory_filters) do
    inventory.set_filter(index, filter)
end
My Mods | If you can't make it perfect, make it adjustable

BinarySpike
Burner Inserter
Burner Inserter
Posts: 16
Joined: Tue Jun 28, 2016 2:15 am
Contact:

Re: Expose entity-ghost Inventory Filters to Lua

Post by BinarySpike »

👍 +1

I'm trying to set filters on cargo-wagon and it looks like I will have to use a similar workaround I used for train schedules: viewtopic.php?f=28&t=109275

That is, when the blueprint is placed, I check the `event.stack.get_blueprint_entities()` for cargo-wagons with filters. If I find any one wagon with a filter, I tag all cargo wagon ghosts made during that tick so when they are built, the tag tells me to check them again.

azaghal
Inserter
Inserter
Posts: 31
Joined: Sat Jun 27, 2020 11:13 am
Contact:

Re: Expose entity-ghost Inventory Filters to Lua

Post by azaghal »

With the 2.0 game release, the player can now modify placed ghost entities - including recipes, filters etc. However... It looks like we still cannot programmatically easily access the "inventories" of ghost entities (primarily for the ability to modify the slot filters as mentioned by the original poster) - unless I am missing some kind of obvious addition in the API.

Is there any chance that this particular interface request can get revisited? Or could we at least get a definitive answer on whether this will implemented or not?

For some context, I am working on updating the Inventory Templates mod for version 2.0. The mod allows user to easily export, import, and clear inventory filters (and bar/slot limits) via templates stored as constant combinators with signals inside of blueprint entities. I was hoping I could easily extend its functionality to cover the ghost entities as well. The mod does have some overlap with the functionality with the 2.0 feature additions, but I still think it provides a lot of value because you can template the player inventory, and get an easier overview of what the filters would be set to (because they would be visible in the blueprint itself) at a glance.

Thank you for all the work on modding capabilities of the game usual. :)

Best regards,
Branko

Post Reply

Return to “Modding interface requests”