Модуль:Prototypes/Механика/Награда доставки: различия между версиями
Материал из Space Station 14 Вики
Pok (обсуждение | вклад) мНет описания правки Метка: ручная отмена |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 1: | Строка 1: | ||
-- Загрузка данных | -- Загрузка данных | ||
local cargoData = mw.loadData("Модуль:IanComradeBot/prototypes/cargo/bounty.json/base") | local cargoData = mw.loadData("Модуль:IanComradeBot/prototypes/cargo/bounty.json/base") | ||
function p. | local p = {} | ||
function p.table(frame) | |||
local output = {} | |||
for _, item in pairs(cargoData) do | |||
local reward = item.reward or "" | |||
local description = item.description or "" | |||
if item.entries then | |||
for _, entry in ipairs(item.entries) do | |||
local product = entry.name or "" | |||
local amount = entry.amount or "" | |||
table.insert(output, '|data-sort-value=' .. reward .. '|') | |||
local cellTemplate = string.format( | |||
"{{Cut-Layout|1=<b>{{color|#{{ColorPalette|Threat codes|Gamma}}|%s x%s}}</b>|2={{ColorPalette|Other|price|$%s}}|3=%s}}", | |||
frame:preprocess('{{#invoke:Ftl|main|translation|' .. product .. '}}'), | |||
amount, | |||
reward, | |||
frame:preprocess('{{#invoke:Ftl|main|translation|' .. description .. '}}') | |||
) | |||
table.insert(output, cellTemplate) | |||
table.insert(output, '|-') | |||
end | |||
end | |||
end | |||
return frame:preprocess(table.concat(output, "\n")) | |||
end | end | ||
return p | return p | ||
Версия от 20:38, 15 апреля 2025
Для документации этого модуля может быть создана страница Модуль:Prototypes/Механика/Награда доставки/doc
-- Загрузка данных
local cargoData = mw.loadData("Модуль:IanComradeBot/prototypes/cargo/bounty.json/base")
local p = {}
function p.table(frame)
local output = {}
for _, item in pairs(cargoData) do
local reward = item.reward or ""
local description = item.description or ""
if item.entries then
for _, entry in ipairs(item.entries) do
local product = entry.name or ""
local amount = entry.amount or ""
table.insert(output, '|data-sort-value=' .. reward .. '|')
local cellTemplate = string.format(
"{{Cut-Layout|1=<b>{{color|#{{ColorPalette|Threat codes|Gamma}}|%s x%s}}</b>|2={{ColorPalette|Other|price|$%s}}|3=%s}}",
frame:preprocess('{{#invoke:Ftl|main|translation|' .. product .. '}}'),
amount,
reward,
frame:preprocess('{{#invoke:Ftl|main|translation|' .. description .. '}}')
)
table.insert(output, cellTemplate)
table.insert(output, '|-')
end
end
end
return frame:preprocess(table.concat(output, "\n"))
end
return p