Модуль:Prototypes/Хранилище/Предмет: различия между версиями
Pok (обсуждение | вклад) Отмена правки 71966, сделанной Pok (обсуждение) Метка: отмена |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 6: | Строка 6: | ||
local itemSlotsData = mw.loadData("Модуль:IanComradeBot/prototypes/ItemSlots.json/data") | local itemSlotsData = mw.loadData("Модуль:IanComradeBot/prototypes/ItemSlots.json/data") | ||
local itemStackData = mw.loadData("Модуль:IanComradeBot/prototypes/fills/stack.json/data") | local itemStackData = mw.loadData("Модуль:IanComradeBot/prototypes/fills/stack.json/data") | ||
local chemTranslateData = mw.loadData("Модуль:IanComradeBot/chem prototypes.json/data") | local chemTranslateData = mw.loadData("Модуль:IanComradeBot/chem prototypes.json/data") | ||
| Строка 301: | Строка 300: | ||
end | end | ||
-- Функция для загрузки данных из модуля по типу раствора | |||
local function loadSolutionData(solutionType) | |||
local modulePath = string.format("Модуль:IanComradeBot/prototypes/fills/chem/%s.json/data", solutionType) | |||
return mw.loadData(modulePath) | |||
end | end | ||
local | local function processSolution(solutionType) | ||
local solutionModule = loadSolutionData(solutionType) | |||
if | if not solutionModule or not solutionModule[solutionType] then | ||
return "" | |||
end | end | ||
local solution = solutionModule[solutionType] | |||
local output = "" | local output = "" | ||
if solution and solution.reagents then | if solution and solution.reagents then | ||
for _, reagent in ipairs(solution.reagents) do | for _, reagent in ipairs(solution.reagents) do | ||
local chemInfo = chemTranslateData[reagent.ReagentId] | -- Проверка, чтобы не выводить "Волокно" | ||
if reagent.ReagentId ~= "Fiber" then | |||
local chemInfo = chemTranslateData[reagent.ReagentId] | |||
local displayName = chemInfo and chemInfo.name or reagent.ReagentId | |||
output = output .. string.format( | |||
'<li>[[Химия#chem_%s|%s]] (%d ед.)</li>', | |||
reagent.ReagentId, displayName, reagent.Quantity | |||
) | |||
end | |||
end | end | ||
end | end | ||
| Строка 338: | Строка 331: | ||
local result = "" | local result = "" | ||
-- Перебираем необходимые типы растворов | |||
result = result .. processSolution( | result = result .. processSolution("drink") | ||
result = result .. processSolution( | result = result .. processSolution("beaker") | ||
result = result .. processSolution( | result = result .. processSolution("injector") | ||
result = result .. processSolution( | result = result .. processSolution("pen") | ||
return result ~= "" and string.format('<ul>%s</ul>', result) or '' | return result ~= "" and string.format('<ul>%s</ul>', result) or '' | ||