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

Нет описания правки
Метка: ручная отмена
мНет описания правки
Строка 13: Строка 13:
         min, max = tonumber(min), tonumber(max)
         min, max = tonumber(min), tonumber(max)
         if min and max then
         if min and max then
             result[#result + 1] = string.format('от %d до %d.', min + 1, max + 1)
             result[#result + 1] = string.format('[%d-%d]', min + 1, max + 1)
         else
         else
             result[#result + 1] = 'Некорректный формат для range.'
             result[#result + 1] = 'Некорректный формат для range.'
Строка 19: Строка 19:
     elseif rolls and rolls.value then
     elseif rolls and rolls.value then
         -- Если указано value
         -- Если указано value
         result[#result + 1] = string.format('Будет сгенерировано %d предметов.', rolls.value)
         result[#result + 1] = string.format('[%d]', rolls.value)
     else
     else
         result[#result + 1] = 'Не указан параметр rolls.'
         result[#result + 1] = 'Не указан параметр rolls.'
Строка 179: Строка 179:
     -- Проверка для контейнера EntityTableContainerFill
     -- Проверка для контейнера EntityTableContainerFill
     if groupSelector.weight and groupSelector.weight ~= "default" then
     if groupSelector.weight and groupSelector.weight ~= "default" then
         wrapperStart = string.format('<div class="together" id="%s">', groupSelector.weight)
         wrapperStart = string.format('{{LinkСard/Сollapsible|name=Группа [%s]|content=', groupSelector.weight)
         wrapperEnd = "</div>"
         wrapperEnd = "}}"
     elseif groupSelector["!type"] == "GroupSelector" and not groupSelector.weight then
     elseif groupSelector["!type"] == "GroupSelector" and not groupSelector.weight then
         wrapperStart = '<div class="EntityFill">'
         wrapperStart = '{{LinkСard/Сollapsible|name=Попадаётся только один из|content='
         wrapperEnd = "</div>"
         wrapperEnd = "}}"
     end
     end


Строка 190: Строка 190:
             result[#result + 1] = handleGroupSelector(child)
             result[#result + 1] = handleGroupSelector(child)
         elseif child["!type"] == "AllSelector" then
         elseif child["!type"] == "AllSelector" then
             result[#result + 1] = string.format('<div class="AllSelector">%s</div>', handleAllSelector(child))
             result[#result + 1] = string.format('{{LinkСard/Сollapsible|name=Попадаются только вместе|content=%s}}', handleAllSelector(child))
         elseif child.id then
         elseif child.id then
             result[#result + 1] = formatContent(child)
             result[#result + 1] = formatContent(child)
Строка 206: Строка 206:


     local result = {}
     local result = {}
    local classes = {}


     if wrapped then
     if wrapped then
         if nestedSelector.rolls and nestedSelector.rolls.range then
         if nestedSelector.rolls and nestedSelector.rolls.range then
             classes[#classes + 1] = 'rolls-' .. processRolls(nestedSelector.rolls)
             local classesRolls = processRolls(nestedSelector.rolls)
         end
         end
         if nestedSelector.prob then
         if nestedSelector.prob then
             classes[#classes + 1] = 'prob-' .. tostring(math.floor(nestedSelector.prob * 100)) .. 'p'
             local classesProb = string.format(" <div>%s%%</div>", content.prob * 100 >= 1 and math.floor(content.prob * 100) or content.prob * 100)
         end
         end
     end
     end


     if wrapped and #classes > 0 then
     if wrapped and #classes > 0 then
         result[#result + 1] = string.format('<div class="%s">', table.concat(classes, ' '))
         result[#result + 1] = string.format('{{LinkСard/Сollapsible|name=Группа %s%s|content=', classesRolls, classesProb)
     end
     end


     result[#result + 1] = getTableOutput(nestedSelector.tableId)
     result[#result + 1] = getTableOutput(nestedSelector.tableId)


     if wrapped and #classes > 0 then
     if wrapped and classesRolls and classesProb > 0 then
         result[#result + 1] = "</div>"
         result[#result + 1] = "}}"
     end
     end


Строка 286: Строка 285:
         end
         end


         return 'Режим rolls не найден для этого ID.'
         return ''
     else
     else
         return 'Неизвестный режим: ' .. mode
         return 'Неизвестный режим: ' .. mode