Модуль:Prototypes/Хранилище/Предмет: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 79: | Строка 79: | ||
return nil -- На случай, если ничего не выбрано (теоретически невозможно) | return nil -- На случай, если ничего не выбрано (теоретически невозможно) | ||
end | |||
-- Обработка AllSelector | |||
local function processAllSelectors(children) | |||
local result = '' | |||
for _, child in ipairs(children) do | |||
if child.id then | |||
result = result .. formatContent(child) | |||
elseif child["!type"] == "GroupSelector" and child.children then | |||
result = result .. processNestedSelectors(child.children, 1) | |||
elseif child["!type"] == "AllSelector" and child.children then | |||
result = result .. processAllSelectors(child.children) | |||
elseif child["!type"] == "NestedSelector" and child.tableId then | |||
local nestedRolls | |||
if child.rolls then | |||
if child.rolls.value then | |||
nestedRolls = child.rolls.value | |||
elseif child.rolls.range then | |||
local rangeParts = {string.match(child.rolls.range, "(%d+),%s*(%d+)")} | |||
nestedRolls = math.random(tonumber(rangeParts[1]), tonumber(rangeParts[2])) | |||
else | |||
nestedRolls = 1 | |||
end | |||
else | |||
nestedRolls = 1 | |||
end | |||
result = result .. getTableOutput(child.tableId, nestedRolls) | |||
end | |||
end | |||
return result | |||
end | end | ||
| Строка 124: | Строка 154: | ||
result = result .. getTableOutput(selectedChild.tableId, nestedRolls) | result = result .. getTableOutput(selectedChild.tableId, nestedRolls) | ||
end | end | ||
end | end | ||
end | end | ||