Модуль:Песочница/Pok: различия между версиями

мНет описания правки
мНет описания правки
Строка 1: Строка 1:
-- Загрузка данных
-- Загрузка данных
local dataModule = mw.loadData("Модуль:Prototypes/Хранилище/Предмет/data")
local dataModule = mw.loadData("Модуль:Prototypes/Хранилище/Предмет/data")
local itemData = dataModule.Item
local allSelectorData = dataModule.AllSelector
local allSelectorData = dataModule.AllSelector


Строка 26: Строка 25:


-- Поиск данных по ID
-- Поиск данных по ID
local function findDataById(itemData, id)
local function findDataById(dataModule, id)
     for _, item in ipairs(itemData) do
     for _, item in ipairs(dataModule) do
         if item.id == id then
         if item.id == id then
             return item
             return item
Строка 112: Строка 111:


-- Формирование списка содержащихся предметов или таблиц
-- Формирование списка содержащихся предметов или таблиц
getContainedOutput = function(itemData, id)
getContainedOutput = function(dataModule, id)
     local item = findDataById(itemData, id)
     local item = findDataById(dataModule, id)
     if not item then return '' end
     if not item then return '' end


Строка 220: Строка 219:


-- Формирование списка химии
-- Формирование списка химии
getChemOutput = function(itemData, id)
getChemOutput = function(dataModule, id)
     local item = findDataById(itemData, id)
     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(itemData, id) .. '}}')
             return frame:preprocess('{{СollapsibleMenu|' .. getChemOutput(dataModule, id) .. '}}')
         elseif subMode == 'contained' then
         elseif subMode == 'contained' then
             return frame:preprocess('{{СollapsibleMenu|' .. getContainedOutput(itemData, id) .. '}}')
             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(itemData, id))
         return frame:preprocess(getChemOutput(dataModule, id))
     elseif mode == 'contained' then
     elseif mode == 'contained' then
         return frame:preprocess(getContainedOutput(itemData, id))
         return frame:preprocess(getContainedOutput(dataModule, id))
     elseif mode == 'rolls' then
     elseif mode == 'rolls' then
         local entity = findDataById(itemData, id)
         local entity = findDataById(dataModule, id)
         if not entity then return 'ID не найден в данных.' end
         if not entity then return 'ID не найден в данных.' end