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

Материал из Space Station 14 Вики
мНет описания правки
Нет описания правки
 
(не показано 18 промежуточных версий этого же участника)
Строка 1: Строка 1:
local p = {}
-- Загрузка данных
-- Загрузка данных
local cargoData = mw.loadData("Модуль:IanComradeBot/prototypes/cargo/bounty.json/base")
local cargoData = mw.loadData("Модуль:IanComradeBot/prototypes/cargo/bounty.json/base")


function p.main()
local p = {}
 
function p.table(frame)
     local output = {}
     local output = {}
     table.insert(output, '{| class="wikitable"')
     table.insert(output, '{| class="sortable-grid sortable"')
    table.insert(output, '! Сортировка (по награде)')
     table.insert(output, '|-')
     table.insert(output, '|-')
    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 ""
        local description = item.description or ""
        local productLines = {}
         if item.entries then
         if item.entries then
             for _, entry in ipairs(item.entries) do
             for _, entry in ipairs(item.entries) do
                 local product = entry.name or ""
                 local productName = frame:preprocess(
                    "{{#invoke:Loc|GetRawString|" .. entry.name .. "}}"
                )
                 local amount = entry.amount or ""
                 local amount = entry.amount or ""
                 table.insert(output, '|-')
                 table.insert(
                table.insert(output, string.format("| {{#invoke:Ftl|main|translation|%s}} x%s || {{ColorPalette|Other|price|%s}}$", product, amount, reward))
                    productLines,
                    string.format("<b>{{цвет|text|gold|c=%s x%s}}</b>", productName, amount)
                )
             end
             end
         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
     end
      
      

Текущая версия от 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