LLWiki正在建设中,欢迎加入我们

模块:Sifreward

来自LLWiki
跳转到导航 跳转到搜索

可在模块:Sifreward/doc创建此模块的帮助文档

local p = {}

local getArgs = require("Module:Arguments").getArgs
local colors = mw.loadData("module:sifreward/data")

function p.main(frame)
	local args = getArgs(frame, {parentOnly = true, removeBlanks = false})
	local arg1, arg2, arg3 = mw.ustring.upper(args[1]), mw.ustring.lower(args[2] or ""), mw.ustring.lower(args[3] or "")

	local r = tostring( mw.html.create('span'):addClass("game-item")
            :wikitext("[[file:SIF "..arg1..".png|40px|link=]]")
        )

	if arg2 == "" then
		return r
	end

        local color, name
	if colors[arg2] then
		color = colors[arg2]
		name = args[3]
	elseif  colors[arg3] then
		color = colors[arg3]
		name = args[2]
	else
		return '<span class="error">Sifreward模板的属性参数错误!</span>'
	end

        return r.." '''"..frame:expandTemplate{title = "color", args = {color, name}}.."'''"
end

return p