My quickbar is empty.
game.player.get_inventory(defines.inventory.player_quickbar)[1].valid is true
game.player.get_inventory(defines.inventory.player_quickbar)[1].name produces "Error: LuaItemStack API call when LuaItemStack was invalid"...
Empty quickbar slot evaluates to valid invalid LuaItemStack
Re: Empty quickbar slot evaluates to valid invalid LuaItemStack
The ItemStack was valid, as the object exists,sparr wrote:My quickbar is empty.
game.player.get_inventory(defines.inventory.player_quickbar)[1].valid is true
game.player.get_inventory(defines.inventory.player_quickbar)[1].name produces "Error: LuaItemStack API call when LuaItemStack was invalid"...
But it was not valud for read, which is what you should check before trying to read from it:
http://lua-api.factorio.com/latest/LuaI ... d_for_read
Is this valid for reading? Differs from the usual valid in that valid will be true even if the item stack is blank but the entity that holds it is still valid.
Re: Empty quickbar slot evaluates to valid invalid LuaItemStack
Thanks!
To be clear, is checking valid_for_read the only way to find out if a specific inventory slot is empty?
To be clear, is checking valid_for_read the only way to find out if a specific inventory slot is empty?
Re: Empty quickbar slot evaluates to valid invalid LuaItemStack
That is correct
slot is valid if it is a slot, slot is valid_for_read if it has something in it.
slot is valid if it is a slot, slot is valid_for_read if it has something in it.
Re: Empty quickbar slot evaluates to valid invalid LuaItemStack
maybe in the error message replace "invalid" with "not valid_for_read"?