Модуль:Prototypes/Механика/Награда доставки: различия между версиями
Материал из Space Station 14 Вики
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) Нет описания правки |
||
| (не показано 9 промежуточных версий этого же участника) | |||
| Строка 1: | Строка 1: | ||
-- Загрузка данных | |||
local cargoData = mw.loadData("Модуль:IanComradeBot/prototypes/cargo/bounty.json/base") | |||
local p = {} | local p = {} | ||
-- | function p.table(frame) | ||
local | local output = {} | ||
table.insert(output, '{| class="sortable-grid sortable"') | |||
table.insert(output, '! Сортировка (по награде)') | |||
table.insert(output, '|-') | |||
for _, item in pairs(cargoData) do | |||
local reward = item.reward or "" | |||
local description = item.description or "" | |||
local productLines = {} | |||
if item.entries then | |||
for _, entry in ipairs(item.entries) do | |||
local productName = frame:preprocess( | |||
"{{#invoke:Loc|GetRawString|" .. entry.name .. "}}" | |||
) | |||
local amount = entry.amount or "" | |||
table.insert( | |||
productLines, | |||
string.format("<b>{{цвет|text|gold|c=%s x%s}}</b>", productName, amount) | |||
) | |||
end | |||
end | |||
local productsParam = table.concat(productLines, "<br/>") | |||
table.insert(output, '|data-sort-value=' .. reward .. '|' ) | |||
local cellTemplate = string.format( | |||
"{{Cut-Layout|1=%s|2=${{ColorPalette|Other|price|%s}}|3=%s}}", | |||
productsParam, | |||
reward, | |||
frame:preprocess( | |||
"{{#invoke:Loc|GetString|" .. description .. "}}" | |||
) | |||
) | |||
table.insert(output, cellTemplate) | |||
table.insert(output, "|-") | |||
end | |||
table.insert(output, "|}") | |||
return frame:preprocess(table.concat(output, "\n")) | |||
end | end | ||
return p | return p | ||
Текущая версия от 12:57, 25 февраля 2026
Для документации этого модуля может быть создана страница Модуль:Prototypes/Механика/Награда доставки/doc
-- Загрузка данных
local cargoData = mw.loadData("Модуль:IanComradeBot/prototypes/cargo/bounty.json/base")
local p = {}
function p.table(frame)
local output = {}
table.insert(output, '{| class="sortable-grid sortable"')
table.insert(output, '! Сортировка (по награде)')
table.insert(output, '|-')
for _, item in pairs(cargoData) do
local reward = item.reward or ""
local description = item.description or ""
local productLines = {}
if item.entries then
for _, entry in ipairs(item.entries) do
local productName = frame:preprocess(
"{{#invoke:Loc|GetRawString|" .. entry.name .. "}}"
)
local amount = entry.amount or ""
table.insert(
productLines,
string.format("<b>{{цвет|text|gold|c=%s x%s}}</b>", productName, amount)
)
end
end
local productsParam = table.concat(productLines, "<br/>")
table.insert(output, '|data-sort-value=' .. reward .. '|' )
local cellTemplate = string.format(
"{{Cut-Layout|1=%s|2=${{ColorPalette|Other|price|%s}}|3=%s}}",
productsParam,
reward,
frame:preprocess(
"{{#invoke:Loc|GetString|" .. description .. "}}"
)
)
table.insert(output, cellTemplate)
table.insert(output, "|-")
end
table.insert(output, "|}")
return frame:preprocess(table.concat(output, "\n"))
end
return p