Both of these code snippets swap in the "top-most" power-armor-mk2 in my inventory, but temporarily shrink the size of my inventory, typically dropping a bunch of stuff on the ground:
Code: Select all
/c wornArmor = game.player.get_inventory(defines.inventory.character_armor)[1]
newArmor = game.player.get_main_inventory().find_item_stack("power-armor-mk2")
newArmor.swap_stack(wornArmor)
Code: Select all
/c wornArmor = game.player.get_inventory(defines.inventory.character_armor)[1]
newArmor = game.player.get_main_inventory().find_item_stack("power-armor-mk2")
wornArmor.swap_stack(newArmor)