Модуль:Prototypes/Роль/Экипировка: различия между версиями

мНет описания правки
мНет описания правки
Строка 82: Строка 82:


     local gearEquipment = gear.equipment or {}
     local gearEquipment = gear.equipment or {}
 
   
     -- 1. Сначала пытаемся получить экипировку из gearData
     -- 1. Сначала пытаемся получить экипировку из gearData
     local itemId = gearEquipment[slot] or ""
     local itemId = gearEquipment[slot] or ""
Строка 94: Строка 94:
             for _, groupId in ipairs(roleLoadoutData.groups or {}) do
             for _, groupId in ipairs(roleLoadoutData.groups or {}) do
                 if groupId ~= "Trinkets" then  -- исключаем Trinkets
                 if groupId ~= "Trinkets" then  -- исключаем Trinkets
                     local groupFound = nil
                     local groupFound = findById(gearloadoutGroup, groupId)
                    for _, group in ipairs(gearloadoutGroup) do
                     if groupFound and type(groupFound.loadouts) == "table" then
                        if group.id == groupId then
                        for _, loadoutID in ipairs(groupFound.loadouts) do
                            groupFound = group
                            local loadout = findById(gearloadout, loadoutID)
                            break
                            if loadout and not loadout.effects and loadout.equipment and loadout.equipment[slot] then
                        end
                                itemId = loadout.equipment[slot]
                    end
                                sourceGear = loadout
                     if groupFound then
                                 break
                        if type(groupFound.loadouts) == "table" then
                            for _, loadoutID in ipairs(groupFound.loadouts) do
                                for _, loadout in ipairs(gearloadout) do
                                    if loadout.id == loadoutID then
                                        -- Если loadout имеет effects, то пропускаем его
                                        if loadout.effects then
                                            break
                                        end
                                        if loadout.equipment and loadout.equipment[slot] then
                                            itemId = loadout.equipment[slot]
                                            sourceGear = loadout
                                            break
                                        end
                                    end
                                 end
                                if itemId ~= "" then break end
                             end
                             end
                         end
                         end
Строка 125: Строка 109:
             end
             end
         end
         end
    end
   
    -- 3. Если экипировка не найдена в roleLoadout, проверяем gearData (startingGear)
    if itemId == "" then
        itemId = gearEquipment[slot] or ""
     end
     end


     -- 3. Если экипировка так и не найдена, возвращаем пустую строку
     -- 4. Если экипировка так и не найдена, возвращаем пустую строку
     if itemId == "" then
     if itemId == "" then
         return ""
         return ""
     end
     end


     -- 4. Если слот "back", добавляем содержимое из storage
     -- 5. Если слот "back", добавляем содержимое из storage
     local result
     local result
     if slot == "back" and sourceGear.storage and sourceGear.storage.back then
     if slot == "back" and sourceGear.storage and sourceGear.storage.back then