Модуль:Prototypes/Хранилище/Предмет: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 71: | Строка 71: | ||
local groupSelector = tableData['!type:GroupSelector'] | local groupSelector = tableData['!type:GroupSelector'] | ||
if | if groupSelector and groupSelector.children then | ||
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 | end | ||
return result | |||
elseif tableData['!type:NestedSelector'] and tableData.children then | |||
return processNestedSelectors(tableData.children) | |||
end | end | ||
return | return 'Таблица не содержит элементов.' | ||
end | end | ||
| Строка 110: | Строка 112: | ||
local containers = item.EntityTableContainerFill.containers | local containers = item.EntityTableContainerFill.containers | ||
if containers.entity_storage then | if containers.entity_storage then | ||
local | local children = containers.entity_storage.children | ||
if tableId then | if children then | ||
for _, child in ipairs(children) do | |||
if child["!type"] == "NestedSelector" and child.tableId then | |||
result = result .. getTableOutput(child.tableId) | |||
elseif child["!type"] == "GroupSelector" then | |||
local groupSelectors = {} | |||
local weight = child.weight or "default" | |||
groupSelectors[weight] = groupSelectors[weight] or {} | |||
table.insert(groupSelectors[weight], child.children) | |||
-- Генерация 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 | |||
elseif child.id then | |||
result = result .. formatContent(child) | |||
end | |||
end | |||
end | end | ||
end | end | ||