Модуль:Местонахождение: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) м Замена текста — «IanComradeBot/prototypes/сargo.json/data» на «IanComradeBot/prototypes/cargo.json/data» |
||
| (не показана 1 промежуточная версия этого же участника) | |||
| Строка 15: | Строка 15: | ||
local itemBorgData = mw.loadData("Модуль:IanComradeBot/prototypes/ItemBorgModule.json/data") | local itemBorgData = mw.loadData("Модуль:IanComradeBot/prototypes/ItemBorgModule.json/data") | ||
local cargoData = mw.loadData("Модуль:IanComradeBot/prototypes/ | local cargoData = mw.loadData("Модуль:IanComradeBot/prototypes/cargo.json/data") | ||
local latheData = mw.loadData("Модуль:IanComradeBot/prototypes/lathe.json/data") | local latheData = mw.loadData("Модуль:IanComradeBot/prototypes/lathe.json/data") | ||
| Строка 74: | Строка 74: | ||
-- Формирование ссылки для роли/джоба (reverseEquipment) | -- Формирование ссылки для роли/джоба (reverseEquipment) | ||
local function createJobLink(jobId) | local function createJobLink(jobId) | ||
local translation = "{{#invoke:Ftl|main|translation|" .. jobId .. "}}" | local translation = "{{#invoke:Ftl|main|translation|Job" .. jobId .. "}}" | ||
return "[[" .. translation .. "|{{ucfirst:" .. translation .. "}}]]" | return "[[" .. translation .. "|{{ucfirst:" .. translation .. "}}]]" | ||
end | end | ||
| Строка 188: | Строка 188: | ||
local resultsMap = {} | local resultsMap = {} | ||
-- Обработка startingGear (gearData) | -- Обработка startingGear (gearData) | ||
for _, gear in pairs(gearData) do | for _, gear in pairs(gearData) do | ||
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 | ||
for | local gearId = gear.id | ||
if gearId then | |||
for _, job in ipairs(jobData) do | |||
if job.startingGear == gearId then | |||
resultsMap[job.id] = true | |||
end | |||
end | end | ||
end | end | ||
| Строка 205: | Строка 206: | ||
end | end | ||
end | end | ||
-- loadout + loadoutGroup + roleLoadout | |||
-- | |||
for _, loadout in pairs(loadoutData) do | for _, loadout in pairs(loadoutData) do | ||
if loadout.equipment then | if loadout.equipment then | ||
for slot, equipId in pairs(loadout.equipment) do | for slot, equipId in pairs(loadout.equipment) do | ||
if equipId == targetId and (not slotFilter or slot == slotFilter) then | if equipId == targetId and (not slotFilter or slot == slotFilter) then | ||
for _, group in pairs(loadoutGroupData) do | for _, group in pairs(loadoutGroupData) do | ||
if group.loadouts and type(group.loadouts) == "table" then | if group.loadouts and type(group.loadouts) == "table" then | ||
for _, lId in ipairs(group.loadouts) do | for _, lId in ipairs(group.loadouts) do | ||
if lId == loadout.id then | if lId == loadout.id then | ||
for _, role in pairs(gearRoleLoadout) do | for _, role in pairs(gearRoleLoadout) do | ||
if role.groups and type(role.groups) == "table" then | if role.groups and type(role.groups) == "table" then | ||
for _, g in ipairs(role.groups) do | for _, g in ipairs(role.groups) do | ||
if g == group.id then | if g == group.id then | ||
local moduleKey = role.id:gsub("^Job", "") | |||
resultsMap[moduleKey] = true | |||
end | end | ||
end | end | ||
| Строка 234: | Строка 233: | ||
end | end | ||
end | end | ||
-- Собираем результаты, убираем дубликаты | -- Собираем результаты, убираем дубликаты | ||
| Строка 264: | Строка 264: | ||
if #directCargo > 0 then | if #directCargo > 0 then | ||
local links = {} | |||
for _, storage in ipairs(directCargo) do | |||
table.insert(links, createCargoLink(storage)) | |||
end | |||
return table.concat(links, ", ") | |||
end | end | ||