Help (Access to blueprint-book)

Place to get help with not working mods / modding interface.
Post Reply
Tanatos
Burner Inserter
Burner Inserter
Posts: 8
Joined: Sun Jul 10, 2016 8:04 pm
Contact:

Help (Access to blueprint-book)

Post by Tanatos »

Primitive code without further checks.

Code: Select all

-- blueprint-book. Item 1,2 and 8 real blueprint
local cursor_stack = player.cursor_stack
-- Active Item in Book. Get blueprint: "item_active[1]"
local item_active = cursor_stack.get_inventory(defines.inventory.item_active)
-- Stored Items in Book. Get blueprint: "item_main[1..30]" 
local item_main = cursor_stack.get_inventory(defines.inventory.item_main)
-- Real blueprint`s in Book (without active)
local Count = item_main.get_item_count("blueprint")
-- Size of Book, default 30
local Size = #item_main

item_main[1].valid -- Ok
item_main[1].label -- Ok
item_main[2].valid -- Ok
item_main[2].label -- Ok

item_main[3].valid -- Ok
item_main[3].label -- Error: "LuaItemStack API call when LuaItemStack was invalid."
-- How check!?
--
item_main[8].valid -- Ok
item_main[8].label -- Ok
How to check the item in the book: it is empty or not? For example, the book contains a valid blueprint 1, 2 and 8 slots.

All 30 elements return true for checking "item_main [2] .valid"
Elements 1,2 and 8 are LuaItemStack, you can call the "name", "label", etc.
All other elements generate an error when calling "LuaItemStack API call when LuaItemStack was invalid."

User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: Help (Access to blueprint-book)

Post by prg »

Use .valid_for_read instead of .valid.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

Tanatos
Burner Inserter
Burner Inserter
Posts: 8
Joined: Sun Jul 10, 2016 8:04 pm
Contact:

Re: Help (Access to blueprint-book)

Post by Tanatos »

Working! Thank you for your prompt response.

Post Reply

Return to “Modding help”