Модуль:Prototypes/Хранилище/Предмет: различия между версиями
Pok (обсуждение | вклад) Нет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 187: | Строка 187: | ||
result[#result + 1] = "</div>" | result[#result + 1] = "</div>" | ||
end | end | ||
-- Обработка rolls | |||
processRolls = function(rolls) | |||
local result = {} | |||
if 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.value then | |||
-- Если указано value | |||
result[#result + 1] = string.format('Будет сгенерировано %d предметов.', rolls.value) | |||
else | |||
result[#result + 1] = 'Не указан параметр rolls.' | |||
end | |||
return table.concat(result) | |||
end | |||
return table.concat(result) | return table.concat(result) | ||
| Строка 236: | Строка 257: | ||
elseif mode == 'contained' then | elseif mode == 'contained' then | ||
return frame:preprocess(getContainedOutput(dataIndex, id)) | return frame:preprocess(getContainedOutput(dataIndex, id)) | ||
elseif mode == 'rolls' then | |||
local entity = findDataById(dataIndex, id) | |||
if not entity then return 'ID не найден в данных.' end | |||
if entity.EntityTableContainerFill then | |||
local containers = entity.EntityTableContainerFill.containers | |||
if containers.entity_storage and containers.entity_storage.rolls then | |||
return processRolls(containers.entity_storage.rolls) | |||
end | |||
end | |||
return 'Режим rolls не найден для этого ID.' | |||
else | |||
return 'Неизвестный режим: ' .. mode | |||
end | end | ||
end | end | ||
return p | return p | ||