How to access blueprints in wagon?

Things that already exist in the current mod API
Post Reply
adamius
Long Handed Inserter
Long Handed Inserter
Posts: 73
Joined: Mon Mar 19, 2018 9:18 am
Contact:

How to access blueprints in wagon?

Post 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

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: How to access blueprints in wagon?

Post 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

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: How to access blueprints in wagon?

Post 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

adamius
Long Handed Inserter
Long Handed Inserter
Posts: 73
Joined: Mon Mar 19, 2018 9:18 am
Contact:

Re: How to access blueprints in wagon?

Post by adamius »

thanks, I'll give these a try.

Post Reply

Return to “Already exists”