From a24c948ee1a0d8678c33cbf19c5a230a413d589e Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Sun, 27 Oct 2024 10:02:11 +0100 Subject: [PATCH] Mtn: insert equipment directly at armor --- maps/mountain_fortress_v3/functions.lua | 18 +++++++++++++++++- utils/commands/misc.lua | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/maps/mountain_fortress_v3/functions.lua b/maps/mountain_fortress_v3/functions.lua index 06164d4d1..9c670e05e 100644 --- a/maps/mountain_fortress_v3/functions.lua +++ b/maps/mountain_fortress_v3/functions.lua @@ -1973,8 +1973,24 @@ function Public.equip_players(starting_items, recreate) Modifiers.update_player_modifiers(player) if not recreate then starting_items = starting_items or this.starting_items + if this.starting_items['modular-armor'] then + player.insert({ name = 'modular-armor', count = 1 }) + end + for item, item_data in pairs(this.starting_items) do - player.insert({ name = item, count = item_data.count }) + if item ~= 'modular-armor' then + local equip = prototypes.equipment[item] + if equip then + local p_armor = player.get_inventory(defines.inventory.character_armor) + if p_armor and p_armor.valid and p_armor[1] and p_armor[1].grid then + for _ = 1, item_data.count do + p_armor[1].grid.put({ name = item }) + end + end + else + player.insert({ name = item, count = item_data.count }) + end + end end end Public.show_all_gui(player) diff --git a/utils/commands/misc.lua b/utils/commands/misc.lua index af15ac3a7..44ffab87e 100644 --- a/utils/commands/misc.lua +++ b/utils/commands/misc.lua @@ -367,7 +367,7 @@ function Public.insert_all_items(player) this.players[player.index] = true - local p_armor = player.get_inventory(5)[1].grid + local p_armor = player.get_inventory(defines.inventory.character_armor)[1].grid if p_armor and p_armor.valid then p_armor.put({ name = 'fission-reactor-equipment', quality = quality }) p_armor.put({ name = 'fission-reactor-equipment', quality = quality })