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: 61
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.

Post Reply

Return to “Modding interface requests”