Модуль:Местонахождение: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 12: | Строка 12: | ||
local loadoutData = mw.loadData("Модуль:IanComradeBot/loadout.json/data") | local loadoutData = mw.loadData("Модуль:IanComradeBot/loadout.json/data") | ||
local loadoutGroupData = mw.loadData("Модуль:IanComradeBot/loadoutGroup.json/data") | local loadoutGroupData = mw.loadData("Модуль:IanComradeBot/loadoutGroup.json/data") | ||
local itemBorgData = mw.loadData("Модуль:IanComradeBot/prototypes/ItemBorgModule.json/data") | |||
local cargoData = mw.loadData("Модуль:IanComradeBot/prototypes/сargo.json/base") | local cargoData = mw.loadData("Модуль:IanComradeBot/prototypes/сargo.json/base") | ||
| Строка 419: | Строка 421: | ||
return table.concat(links, ", ") | return table.concat(links, ", ") | ||
end | |||
function p.reverseBorg(frame) | |||
local targetItem = frame.args[2] | |||
if not targetItem or targetItem == "" then | |||
return "Ошибка: не указан искомый элемент для поиска в ItemBorgModule." | |||
end | |||
local results = {} | |||
-- Проходим по всем записям из itemBorgData | |||
for _, entry in pairs(itemBorgData) do | |||
if type(entry) == "table" and entry.ItemBorgModule and type(entry.ItemBorgModule) == "table" then | |||
local items = entry.ItemBorgModule.items | |||
if type(items) == "table" then | |||
for _, item in ipairs(items) do | |||
if item == targetItem then | |||
table.insert(results, createEntityLink(entry.id)) | |||
break | |||
end | |||
end | |||
end | |||
end | |||
end | |||
if #results == 0 then | |||
return "" | |||
end | |||
return table.concat(results, ", ") | |||
end | end | ||
| Строка 436: | Строка 467: | ||
reverseLathe = p.reverseLathe, | reverseLathe = p.reverseLathe, | ||
reverseVending = p.reverseVending, | reverseVending = p.reverseVending, | ||
reverseBorg = p.reverseBorg, | |||
} | } | ||