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

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


local p = {}
local p = {}
Строка 25: Строка 25:


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


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


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


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