Script to test this out:
Iterating over all inventories just like the example in the LuaControl::get_max_inventory_index documentationCode: Select all
--control.lua
script.on_event(defines.events.on_built_entity, function(event)
local entity = event.entity
if entity.name == "transport-belt" then
for i = 1, entity.get_max_inventory_index() do
local inventory = entity.get_inventory(i)
game.print("inv " .. i .. ": " .. type(inventory))
end
end
end)
Expected Behaviour
I would expect one of:- get_inventory(i) not to return nil but an actual LuaInventory instead, which then could be modified
- get_max_inventory_index() to return 0
If I've made a mistake and this is actually working as intended, please tell me so and excuse me for bothering with this


