Модуль:Prototypes/Хранилище/Предмет: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) Нет описания правки Метка: ручная отмена |
||
| Строка 3: | Строка 3: | ||
-- Кэш данных | -- Кэш данных | ||
local dataCache = {} | local dataCache = {} | ||
-- Функция processRolls для преобразования диапазона | -- Функция processRolls для преобразования диапазона | ||
| Строка 41: | Строка 40: | ||
-- Создание хэш-таблицы для быстрого поиска по ID | -- Создание хэш-таблицы для быстрого поиска по ID | ||
local function buildIndex(data) | local function buildIndex(data) | ||
if not data then return {} end | if not data then return {} end | ||
local index = {} | local index = {} | ||
| Строка 47: | Строка 45: | ||
index[item.id] = item | index[item.id] = item | ||
end | end | ||
return index | return index | ||
end | end | ||
| Строка 92: | Строка 89: | ||
-- Обработка вложенных таблиц | -- Обработка вложенных таблиц | ||
processNestedSelectors = function(children) | processNestedSelectors = function(children) | ||
local result = {} | |||
local | |||
for _, child in ipairs(children) do | for _, child in ipairs(children) do | ||
if child.id then | if child.id then | ||
result[#result + 1] = formatContent(child) | |||
elseif child["!type"] == "NestedSelector" | elseif child["!type"] == "NestedSelector" and child.tableId then | ||
result[#result + 1] = handleNestedSelector(child, true) | |||
elseif child["!type"] == "GroupSelector" then | elseif child["!type"] == "GroupSelector" then | ||
result[#result + 1] = handleGroupSelector(child) | |||
end | end | ||
end | end | ||
return table.concat(result) | |||
return table.concat( | |||
end | end | ||
| Строка 278: | Строка 266: | ||
local entity = findDataById(dataIndex, id) | local entity = findDataById(dataIndex, id) | ||
if not entity then return 'ID не найден в данных.' end | if not entity then return 'ID не найден в данных.' end | ||
if entity.EntityTableContainerFill then | if entity.EntityTableContainerFill then | ||
local containers = entity.EntityTableContainerFill.containers | local containers = entity.EntityTableContainerFill.containers | ||
| Строка 287: | Строка 275: | ||
return 'Режим rolls не найден для этого ID.' | return 'Режим rolls не найден для этого ID.' | ||
else | |||
return 'Неизвестный режим: ' .. mode | return 'Неизвестный режим: ' .. mode | ||
end | end | ||