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

мНет описания правки
мНет описания правки
Строка 123: Строка 123:
                 for _, child in ipairs(children) do
                 for _, child in ipairs(children) do
                     if child["!type"] == "NestedSelector" and child.tableId then
                     if child["!type"] == "NestedSelector" and child.tableId then
                         result = result .. getTableOutput(child.tableId)
                         result = result .. handleNestedSelector(child)
                     elseif child["!type"] == "GroupSelector" then
                     elseif child["!type"] == "GroupSelector" then
                        -- Обработка GroupSelector
                         result = result .. handleGroupSelector(child)
                         result = result .. handleGroupSelector(child)
                    elseif child["!type"] == "AllSelector" then
                        result = result .. handleAllSelector(child)
                     elseif child.id then
                     elseif child.id then
                         result = result .. formatContent(child)
                         result = result .. formatContent(child)
Строка 166: Строка 167:
         result = result .. '</div>'
         result = result .. '</div>'
     end
     end
    return result
end
-- Обработка AllSelector
handleAllSelector = function(allSelector)
    local result = ''
    if not allSelector.children then return result end
    for _, child in ipairs(allSelector.children) do
        if child["!type"] == "NestedSelector" and child.tableId then
            result = result .. handleNestedSelector(child)
        elseif child.id then
            result = result .. formatContent(child)
        end
    end
    return result
end
-- Обработка NestedSelector
handleNestedSelector = function(nestedSelector)
    local result = ''
    local tableId = nestedSelector.tableId
    if not tableId then return result end
    -- Генерация классов для div
    local classes = {}
    if nestedSelector.rolls and nestedSelector.rolls.range then
        table.insert(classes, 'rolls-' .. tostring(nestedSelector.rolls.range):gsub(',', '-'))
    end
    if nestedSelector.prob then
        table.insert(classes, 'prob-' .. tostring(nestedSelector.prob):gsub('%.', '_'))
    end
    -- Обёртка div с классами
    local classString = table.concat(classes, ' ')
    result = result .. string.format('<div class="%s">', classString)
    result = result .. getTableOutput(tableId)
    result = result .. '</div>'


     return result
     return result