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

“模块:Sifitem”的版本间差异

来自LLWiki
跳转到导航 跳转到搜索
标签移动版网页编辑 移动版编辑
 
(未显示2个用户的4个中间版本)
第1行: 第1行:
-- Made with ♥ by User:Leranjun
-- @Author: [[User:Leranjun]]


local p = {}
local p = {}
第11行: 第11行:
local item = DATA.AKA[arg1] or arg1
local item = DATA.AKA[arg1] or arg1
local data = DATA.ITEMS[item]
local data = DATA.ITEMS[item]

if data == nil then
if data == nil then
return "<span class=\"error\">错误的道具名!</span>"
return "<span class=\"error\">错误的道具名!</span>"
第19行: 第19行:


local file = data.file or mw.ustring.upper(item)
local file = data.file or mw.ustring.upper(item)
return tostring( mw.html.create('span'):addClass("game-item")
local r = tostring( mw.html.create('span'):addClass("game-item")
:wikitext(
:wikitext(
"[[file:SIF "..file..
"[[file:SIF "..file..
(data.switch and (data.switch[arg3] or "") or (arg3 and " 有框" or ""))..
(data.switch and data.switch[arg3 or ""] or (arg3 and " 有框" or ""))..
".png|40px|link=]]"
".png|40px|link=]]"
)
)
).." "..(data.before or file.." ")..(arg2 or data.default or "")..(data.after or "")
).." "..(data.before or file.." ")
if arg2 == "" or arg2 == "0" or not (arg2 or data.default) then
return r
end
return r..(arg2 or data.default)..(data.after or "")
end
end



2021年5月7日 (五) 17:42的最新版本

Template-info.png 模块文档
这个文档嵌入模块:Sifitem/doc

该模块实现{{Sifitem}}的功能。

请不要直接调用此模块。

-- @Author: [[User:Leranjun]]

local p = {}

local getArgs = require("Module:Arguments").getArgs
local DATA = mw.loadData("Module:Sifitem/data")

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

    if data == nil then
        return "<span class=\"error\">错误的道具名!</span>"
    elseif data.force2 and arg2 == nil then
        return "<span class=\"error\">模板Sifitem缺失必要参数!</span>"
    end

    local file = data.file or mw.ustring.upper(item)
    local r = tostring( mw.html.create('span'):addClass("game-item")
        :wikitext(
            "[[file:SIF "..file..
            (data.switch and data.switch[arg3 or ""] or (arg3 and " 有框" or ""))..
            ".png|40px|link=]]"
        )
    ).." "..(data.before or file.." ")
    if arg2 == "" or arg2 == "0" or not (arg2 or data.default) then
        return r
    end
    return r..(arg2 or data.default)..(data.after or "")
end

return p