Модуль:Prototypes/Механика/Награда доставки: различия между версиями
Материал из Space Station 14 Вики
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 6: | Строка 6: | ||
function p.table(frame) | function p.table(frame) | ||
local output = {} | local output = {} | ||
table.insert(output, '{| class="sortable-grid sortable"') | |||
table.insert(output, '! Сортировка (по награде)') | |||
table.insert(output, '|-') | |||
for _, item in pairs(cargoData) do | for _, item in pairs(cargoData) do | ||
local reward = item.reward or "" | local reward = item.reward or "" | ||
| Строка 16: | Строка 20: | ||
local cellTemplate = string.format( | local cellTemplate = string.format( | ||
"{{Cut-Layout|1=<b>{{color|#{{ColorPalette|Threat codes|Gamma}}|%s x%s}}</b>|2=${{ColorPalette|Other|price|%s}}|3=%s}}", | "{{Cut-Layout|1=<b>{{color|#{{ColorPalette|Threat codes|Gamma}}|%s x%s}}</b>|2=${{ColorPalette|Other|price|%s}}|3=%s}}", | ||
frame:preprocess( | frame:preprocess("{{#invoke:Ftl|main|translation|" .. product .. "}}"), | ||
amount, | amount, | ||
reward, | reward, | ||
frame:preprocess( | frame:preprocess("{{#invoke:Ftl|main|translation|" .. description .. "}}") | ||
) | ) | ||
table.insert(output, cellTemplate) | table.insert(output, cellTemplate) | ||
table.insert(output, | table.insert(output, "|-") | ||
end | end | ||
end | end | ||
end | end | ||
table.insert(output, "|}") | |||
return frame:preprocess(table.concat(output, "\n")) | return frame:preprocess(table.concat(output, "\n")) | ||
end | end | ||
return p | return p | ||
Версия от 22:32, 15 апреля 2025
Для документации этого модуля может быть создана страница Модуль: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 ""
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
table.insert(output, "|}")
return frame:preprocess(table.concat(output, "\n"))
end
return p