Code: Select all
player.insert{name="power-armor", count=1}
-- instead of in the player, imidiately inside the armor
player.insert{name="personal-roboport-equipment", count=2}
player.insert{name="fusion-reactor-equipment", count=1}
Code: Select all
player.insert{name="power-armor", count=1}
-- instead of in the player, imidiately inside the armor
player.insert{name="personal-roboport-equipment", count=2}
player.insert{name="fusion-reactor-equipment", count=1}
Code: Select all
local armorname = "power-armor"
if player.get_inventory(defines.inventory.player_armor).can_insert(armorname) then
player.insert(armorname)
local armorSlot = player.get_inventory(defines.inventory.player_armor)
if (not armorSlot.is_empty()) then
for j = 1, #armorSlot do
if armorSlot[j].valid_for_read and armorSlot[j].name == armorname then
local armor = armorSlot[j]
game.print("armor active inventory : " .. armor.get_inventory(defines.inventory.item_active)) -- CRASH HERE : LINE 99
game.print("armor main inventory : " .. armor.get_inventory(defines.inventory.item_main))
local armorinventory = armor.get_inventory(defines.inventory.item_active)
local freactor = {name="fusion-reactor-equipment", count=1}
if armorinventory.can_insert(freactor) then
armorinventory.insert(freactor)
end
local proboport = {name="personal-roboport-equipment", count=2}
if armorinventory.can_insert(proboport) then
armorinventory.insert(proboport)
end
end
end
end
end
Code: Select all
Error while running event on_player_joined_game (ID 43)
Given item is not an ItemWithInventory.
stack traceback:
...l/Downloads/factorio/temp/currently-playing/sl_utils.lua:99: in function 'givePlayerItems'
...l/Downloads/factorio/temp/currently-playing/sl_utils.lua:151: in function 'givePlayerStarterItems'
...l/Downloads/factorio/temp/currently-playing/sl_utils.lua:393: in function 'playerSpawnItems'
...sl/Downloads/factorio/temp/currently-playing/control.lua:195: in function <...sl/Downloads/factorio/temp/currently-playing/control.lua:177
Code: Select all
local inv = player.get_inventory(defines.inventory.player_armor)
inv.insert("power-armor-mk2")
local armor = inv[1].grid
armor.put{name="fusion-reactor-equipment"}
armor.put{name="personal-roboport-equipment"}
end
Code: Select all
if armor.grid then
armor.grid.put({name="fusion-reactor-equipment"})
end
Have a look at https://mods.factorio.com/mods/arumba/A ... ated_Start code.Adil wrote:Armor has a grid, not inventory.Code: Select all
if armor.grid then armor.grid.put({name="fusion-reactor-equipment"}) end