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

Материал из Space Station 14 Вики
мНет описания правки
Нет описания правки
 
(не показаны 3 промежуточные версии этого же участника)
Строка 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 ""
         local description = item.description 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, '|data-sort-value=' .. reward .. '|')
                 table.insert(
                local cellTemplate = string.format(
                    productLines,
                    "{{Cut-Layout|1=<b>{{color|#{{ColorPalette|Threat codes|Gamma}}|%s x%s}}</b>|2=${{ColorPalette|Other|price|%s}}|3=%s}}",
                    string.format("<b>{{цвет|text|gold|c=%s x%s}}</b>", productName, amount)
                    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
         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
   
    table.insert(output, "|}")
     return frame:preprocess(table.concat(output, "\n"))
     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