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

Материал из Space Station 14 Вики
мНет описания правки
Метка: ручная отмена
мНет описания правки
Строка 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(frame)
local p = {}
local output = {}
 
table.insert(output, '{| class="wikitable"')
function p.table(frame)
table.insert(output, '|-')
    local output = {}
table.insert(output, '! Продукт (количество)')
    for _, item in pairs(cargoData) do
table.insert(output, '! Вознаграждение')
        local reward = item.reward or ""
table.insert(output, '! Описание')
        local description = item.description or ""
        if item.entries then
for _, item in pairs(cargoData) do
            for _, entry in ipairs(item.entries) do
local reward = item.reward or ""
                local product = entry.name or ""
local description = item.description or ""
                local amount = entry.amount or ""
if item.entries then
                table.insert(output, '|data-sort-value=' .. reward .. '|')
for _, entry in ipairs(item.entries) do
                local cellTemplate = string.format(
local product = entry.name or ""
                    "{{Cut-Layout|1=<b>{{color|#{{ColorPalette|Threat codes|Gamma}}|%s x%s}}</b>|2={{ColorPalette|Other|price|$%s}}|3=%s}}",
local amount = entry.amount or ""
                    frame:preprocess('{{#invoke:Ftl|main|translation|' .. product .. '}}'),
table.insert(output, '|-')
                    amount,
table.insert(output, string.format("| [[{{#invoke:Ftl|main|translation|%s}}|{{#invoke:Ftl|main|translation|%s}}]] x%s || {{ColorPalette|Other|price|%s}}$ || {{#invoke:Ftl|main|translation|%s}}", product, product, amount, reward, description))
                    reward,
end
                    frame:preprocess('{{#invoke:Ftl|main|translation|' .. description .. '}}')
end
                )
end
                table.insert(output, cellTemplate)
                table.insert(output, '|-')
table.insert(output, "|}")
            end
return frame:preprocess(table.concat(output, "\n"))
        end
    end
    return frame:preprocess(table.concat(output, "\n"))
end
end


return p
return p

Версия от 20:38, 15 апреля 2025

Для документации этого модуля может быть создана страница Модуль:Prototypes/Механика/Награда доставки/doc

-- Загрузка данных
local cargoData = mw.loadData("Модуль:IanComradeBot/prototypes/cargo/bounty.json/base")

local p = {}

function p.table(frame)
    local 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
    return frame:preprocess(table.concat(output, "\n"))
end

return p