Модуль:Песочница/Pok: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 1: | Строка 1: | ||
-- Загрузка данных | -- Загрузка данных | ||
local dataModule = mw.loadData("Модуль:Prototypes/Хранилище/Предмет/data") | local dataModule = mw.loadData("Модуль:Prototypes/Хранилище/Предмет/data") | ||
local allSelectorData = dataModule.AllSelector | local allSelectorData = dataModule.AllSelector | ||
| Строка 26: | Строка 25: | ||
-- Поиск данных по ID | -- Поиск данных по ID | ||
local function findDataById( | local function findDataById(dataModule, id) | ||
for _, item in ipairs( | for _, item in ipairs(dataModule) do | ||
if item.id == id then | if item.id == id then | ||
return item | return item | ||
| Строка 112: | Строка 111: | ||
-- Формирование списка содержащихся предметов или таблиц | -- Формирование списка содержащихся предметов или таблиц | ||
getContainedOutput = function( | getContainedOutput = function(dataModule, id) | ||
local item = findDataById( | local item = findDataById(dataModule, id) | ||
if not item then return '' end | if not item then return '' end | ||
| Строка 220: | Строка 219: | ||
-- Формирование списка химии | -- Формирование списка химии | ||
getChemOutput = function( | getChemOutput = function(dataModule, id) | ||
local item = findDataById( | local item = findDataById(dataModule, id) | ||
if not item or not item.SolutionContainerManager or not item.SolutionContainerManager.solutions then return '' end | if not item or not item.SolutionContainerManager or not item.SolutionContainerManager.solutions then return '' end | ||
| Строка 249: | Строка 248: | ||
if subMode == 'chem' then | if subMode == 'chem' then | ||
return frame:preprocess('{{СollapsibleMenu|' .. getChemOutput( | return frame:preprocess('{{СollapsibleMenu|' .. getChemOutput(dataModule, id) .. '}}') | ||
elseif subMode == 'contained' then | elseif subMode == 'contained' then | ||
return frame:preprocess('{{СollapsibleMenu|' .. getContainedOutput( | return frame:preprocess('{{СollapsibleMenu|' .. getContainedOutput(dataModule, id) .. '}}') | ||
else | else | ||
return 'Неизвестный подрежим для framing: ' .. subMode | return 'Неизвестный подрежим для framing: ' .. subMode | ||
end | end | ||
elseif mode == 'chem' then | elseif mode == 'chem' then | ||
return frame:preprocess(getChemOutput( | return frame:preprocess(getChemOutput(dataModule, id)) | ||
elseif mode == 'contained' then | elseif mode == 'contained' then | ||
return frame:preprocess(getContainedOutput( | return frame:preprocess(getContainedOutput(dataModule, id)) | ||
elseif mode == 'rolls' then | elseif mode == 'rolls' then | ||
local entity = findDataById( | local entity = findDataById(dataModule, id) | ||
if not entity then return 'ID не найден в данных.' end | if not entity then return 'ID не найден в данных.' end | ||