[0.12.35] incorrect .valid return
Posted: Fri Jun 03, 2016 6:51 pm
If armor slot is empty, it is valid for some reason. But you cannot access other fields of it.
Code: Select all
script.on_event(defines.events.on_player_created,function(e)
local p=game.players[e.player_index]
local armor=p.get_inventory(defines.inventory.player_armor)[1]
print (armor.valid)
if not (armor and armor.valid and armor.has_grid) then
-this will give error
end
end)
Code: Select all
Error while running the event handler: __Advanced_Personal_Defense__/control.lua:42: LuaItemStack API call when LuaItemStack was invalid