Page 1 of 1

How to access blueprints in wagon?

Posted: Fri Jun 01, 2018 10:46 pm
by adamius
Hi all,

I have a wagon full of blueprints. How do I allow a script to access the blueprint data for the third blueprint in the wagon?

From what I can see LuaStackItem has accessors but I’m not sure how to use it to access individual blueprints.

Thanks

Re: How to access blueprints in wagon?

Posted: Fri Jun 01, 2018 11:21 pm
by Nexela
Assuming you have the wagon already (also untested off thetop ofmy head)

Code: Select all

local inv = WagonEntity.get_inventory(defines.inventory.cargo_wagon)
if inv[3].valid_for_read then
-- inv[3] is the itemstack do stuff
end

Re: How to access blueprints in wagon?

Posted: Fri Jun 01, 2018 11:59 pm
by eradicator
Specifically LuaInventory behaves like a numerically indexed iterable table of LuaItemStack, so you can iterate or directly access numerically.

Code: Select all

for i=1,#LuaInventory do
 local this_stack = LuaInventory[i]
 end

Re: How to access blueprints in wagon?

Posted: Sat Jun 02, 2018 12:16 am
by adamius
thanks, I'll give these a try.