Модуль:Песочница/Pok: различия между версиями

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


     local results = {}
     local results = {}
    -- Поиск в startingGear (gearData)
for _, gear in pairs(gearData) do
    for gearId, gear in pairs(gearData) do
    local currentGearId = gear.id or "Unknown"
        if gear.equipment then
    if gear.equipment then
            for slot, equipId in pairs(gear.equipment) do
        for slot, equipId in pairs(gear.equipment) do
                if equipId == targetId and (not slotFilter or slot == slotFilter) then
            if equipId == targetId and (not slotFilter or slot == slotFilter) then
                    -- Ищем в jobData, где startingGear равен gearId
                local foundJob = nil
                    local foundJob = nil
                for jobId, job in pairs(jobData) do
                    for jobId, job in pairs(jobData) do
                    if job.startingGear == currentGearId then
                        if job.startingGear == gearId then
                        foundJob = jobId
                            foundJob = jobId
                        break
                            break
                    end
                        end
                end
                    end
                if foundJob then
                    if foundJob then
                    table.insert(results, "Job: " .. foundJob .. " (слот: " .. slot .. ")")
                        table.insert(results, "Job: " .. foundJob .. " (слот: " .. slot .. ")")
                else
                    else
                    table.insert(results, "Gear: " .. currentGearId .. " (слот: " .. slot .. ")")
                        table.insert(results, "Gear: " .. gearId .. " (слот: " .. slot .. ")")
                end
                    end
            end
                end
        end
            end
    end
        end
end
    end


     -- Поиск в loadout (loadoutData)
     -- Поиск в loadout (loadoutData)