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

мНет описания правки
мНет описания правки
Строка 26: Строка 26:


-- Поиск данных по ID
-- Поиск данных по ID
local function findDataById(data, id)
local function findDataById(itemData, id)
     for _, item in ipairs(data) do
     for _, item in ipairs(itemData) do
         if item.id == id then
         if item.id == id then
             return item
             return item
Строка 98: Строка 98:
-- Обработка таблиц
-- Обработка таблиц
getTableOutput = function(tableId)
getTableOutput = function(tableId)
    local allSelectors = loadData('User:IanComradeBot/prototypes/AllSelector.json')
     local tableData = findDataById(allSelectorData, tableId)
     local tableData = findDataById(buildIndex(allSelectors), tableId)


     if not tableData then return 'Таблица не найдена.' end
     if not tableData then return 'Таблица не найдена.' end
Строка 113: Строка 112:


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


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


-- Формирование списка химии
-- Формирование списка химии
getChemOutput = function(data, id)
getChemOutput = function(itemData, id)
     local item = findDataById(data, id)
     local item = findDataById(itemData, 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