Модуль:Prototypes/Хранилище/Предмет: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 3: | Строка 3: | ||
-- Кэш данных | -- Кэш данных | ||
local dataCache = {} | local dataCache = {} | ||
local processRolls = function(rolls) | |||
local result = {} | |||
if rolls and rolls.range then | |||
-- Если указан range | |||
local min, max = rolls.range:match("(%d+),%s*(%d+)") | |||
min, max = tonumber(min), tonumber(max) | |||
if min and max then | |||
result[#result + 1] = string.format('Максимальное количество предметов: от %d до %d.', min, max) | |||
else | |||
result[#result + 1] = 'Некорректный формат для range.' | |||
end | |||
elseif rolls and rolls.value then | |||
-- Если указано value | |||
result[#result + 1] = string.format('Будет сгенерировано %d предметов.', rolls.value) | |||
else | |||
result[#result + 1] = 'Не указан параметр rolls.' | |||
end | |||
return table.concat(result) | |||
end | |||
-- Локальные функции | -- Локальные функции | ||
local loadData, findDataById, formatContent, getContentsOutput, processNestedSelectors, getTableOutput, getContainedOutput, getChemOutput, handleGroupSelector, handleAllSelector, handleNestedSelector | local loadData, findDataById, formatContent, getContentsOutput, processNestedSelectors, getTableOutput, getContainedOutput, getChemOutput, handleGroupSelector, handleAllSelector, handleNestedSelector | ||
-- Функция для загрузки данных с кэшированием | -- Функция для загрузки данных с кэшированием | ||
| Строка 188: | Строка 207: | ||
result[#result + 1] = "</div>" | result[#result + 1] = "</div>" | ||
end | end | ||
return table.concat(result) | return table.concat(result) | ||