Модуль:Prototypes/Хранилище/Предмет: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 67: | Строка 67: | ||
local allSelectors = loadData('User:IanComradeBot/prototypes/AllSelector.json') | local allSelectors = loadData('User:IanComradeBot/prototypes/AllSelector.json') | ||
local tableData = findDataById(allSelectors, tableId) | local tableData = findDataById(allSelectors, tableId) | ||
if not | if not tableData then return 'Таблица не найдена.' end | ||
return | local groupSelector = tableData['!type:GroupSelector'] | ||
if not groupSelector or not groupSelector.children then | |||
return 'Таблица не содержит элементов.' | |||
end | |||
local result = '' | |||
local groupSelectors = {} | |||
-- Группируем элементы по weight | |||
for _, child in ipairs(groupSelector.children) do | |||
if child["!type"] == "GroupSelector" then | |||
local weight = child.weight or "default" | |||
groupSelectors[weight] = groupSelectors[weight] or {} | |||
table.insert(groupSelectors[weight], child.children) | |||
end | |||
end | |||
-- Генерация div для каждой группы | |||
for weight, groups in pairs(groupSelectors) do | |||
result = result .. string.format('<div class="together" id="%s">', weight) | |||
for _, group in ipairs(groups) do | |||
result = result .. getContentsOutput(group) | |||
end | |||
result = result .. '</div>' | |||
end | |||
return result | |||
end | end | ||
| Строка 85: | Строка 110: | ||
local containers = item.EntityTableContainerFill.containers | local containers = item.EntityTableContainerFill.containers | ||
if containers.entity_storage then | if containers.entity_storage then | ||
local | local tableId = containers.entity_storage.tableId | ||
if | if tableId then | ||
result = result .. getTableOutput(tableId) | |||
end | end | ||
end | end | ||