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