Модуль:Prototypes/Хранилище/Предмет: различия между версиями

мНет описания правки
мНет описания правки
Строка 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)
    local children = tableData and tableData['!type:AllSelector'] and tableData['!type:AllSelector'].children


     if not children then return 'Таблица не содержит элементов.' end
     if not tableData then return 'Таблица не найдена.' end


     return processNestedSelectors(children)
     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 children = containers.entity_storage.children
             local tableId = containers.entity_storage.tableId
             if children then
             if tableId then
                 local groupSelectors = {}
                 result = result .. getTableOutput(tableId)
 
                for _, child in ipairs(children) do
                    if child["!type"] == "GroupSelector" then
                        local weight = child.weight or "default"
                        groupSelectors[weight] = groupSelectors[weight] or {}
                        table.insert(groupSelectors[weight], child.children)
                    elseif child.tableId then
                        result = result .. getTableOutput(child.tableId)
                    elseif child.id then
                        result = result .. formatContent(child)
                    end
                end
 
                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
             end
         end
         end