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

Материал из Space Station 14 Вики
мНет описания правки
мНет описания правки
Строка 5: Строка 5:


function p.main(frame)
function p.main(frame)
    local output = {}
local output = {}
    table.insert(output, '{| class="wikitable"')
table.insert(output, '{| class="wikitable"')
    table.insert(output, '|-')
table.insert(output, '|-')
    table.insert(output, '! Продукт (количество)')
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 description = item.description or ""
local reward = item.reward or ""
        local reward = item.reward or ""
local description = item.description or ""
        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 product = entry.name or ""
                local amount = entry.amount or ""
local amount = entry.amount or ""
                table.insert(output, '|-')
table.insert(output, '|-')
                table.insert(output, string.format("| [[{{#invoke:Ftl|main|translation|%s}}|{{#invoke:Ftl|main|translation|%s}}]] x%s || {{#invoke:Ftl|main|translation|%s}} || {{ColorPalette|Other|price|%s}}$", product, product, amount, description, reward))
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))
            end
end
        end
end
    end
end
   
    table.insert(output, "|}")
table.insert(output, "|}")
    return frame:preprocess(table.concat(output, "\n"))
return frame:preprocess(table.concat(output, "\n"))
end
end


return p
return p

Версия от 17:37, 22 марта 2025

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

local p = {}

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

function p.main(frame)
	local output = {}
	table.insert(output, '{| class="wikitable"')
	table.insert(output, '|-')
	table.insert(output, '! Продукт (количество)')
	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, '|-')
				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))
			end
		end
	end
	
	table.insert(output, "|}")
	return frame:preprocess(table.concat(output, "\n"))
end

return p