Модуль:Prototypes/Механика/Награда доставки: различия между версиями

Материал из Space Station 14 Вики
мНет описания правки
мНет описания правки
Строка 18: Строка 18:
             for _, entry in ipairs(item.entries) do
             for _, entry in ipairs(item.entries) do
                 local productName = frame:preprocess(
                 local productName = frame:preprocess(
                     "{{#invoke:Ftl|main|translation|" .. entry.name .. "}}"
                     "{{#invoke:Loc|GetString|" .. entry.name .. "}}"
                 )
                 )
                 local amount = entry.amount or ""
                 local amount = entry.amount or ""
Строка 35: Строка 35:
             reward,
             reward,
             frame:preprocess(
             frame:preprocess(
                 "{{#invoke:Ftl|main|translation|" .. description .. "}}"
                 "{{#invoke:Loc|GetString|" .. description .. "}}"
             )
             )
         )
         )

Версия от 11:54, 6 февраля 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|GetString|" .. entry.name .. "}}"
                )
                local amount = entry.amount or ""
                table.insert(
                    productLines,
                    string.format("<b>{{color|#{{ColorPalette|Threat codes|Gamma}}|%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