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

模块:Asitem

来自LLWiki
跳转到导航 跳转到搜索
Template-info.png 模块文档
这个文档嵌入模块:Asitem/doc
图标名称 代码示例 效果 备注
G、金币 {{asitem|g|100000}} AS 金币.png 金币 100000
星石 {{asitem|星石|10}} AS 爱星.png 爱星 10个
经验 {{asitem|exp|100000}} AS 经验值.png 经验值 100000
马、马卡龙 {{asitem|马|smile|1|150}} AS 桃色马卡龙 1.png 桃色马卡龙★1 150个
{{asitem|马卡龙|红|2|150}} AS 红色马卡龙 2.png 红色马卡龙★2 150个
{{asitem|马卡龙|银色|3|0}} AS 银色马卡龙 3.png 银色马卡龙★3
{{asitem|马卡龙|all|3|0}} 40px all马卡龙★3
{{asitem|书|vo|1|15}} AS 热度类型 入门书.png 热度类型入门书 15本
{{asitem|书|sp|2|0}} AS SP类型 中级书.png SP类型中级书
{{asitem|花|vo|1|15}} AS 热度类型 种子.png 热度类型种子 15棵
{{asitem|花|sp|2|0}} AS SP类型 嫩芽.png SP类型嫩芽
local p = {}

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

function p.main(frame)
    local args = getArgs(frame, {parentOnly = true, removeBlanks = false})
    local arg1, arg2, arg3, arg4 = mw.ustring.lower(args[1] or ""), mw.ustring.lower(args[2] or ""), mw.ustring.lower(args[3] or ""), mw.ustring.lower(args[4] or "")
    local item = DATA.AKA[arg1] or arg1
    local number = arg4
    if number == "" then number = arg2 end
    local type, level
    if number == arg4 then
    	type = DATA.INFO[arg2] or arg2
    	if DATA.INFO[item] then
    	    level = DATA.INFO[item][arg3] or arg3
    	else
    	    level = arg3
    	end
    end
    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\">模板Asitem缺失必要参数!</span>"
    end

    local file
    if number == arg2 then
        file = data.file or mw.ustring.upper(item)
    else
        file = type..data.file.." "..level
    end
    local r = tostring( mw.html.create('span'):addClass("game-item")
        :wikitext(
            "[[file:AS "..file..".png|40px|link=]]"
        )
    ).." "
    if item == "马卡龙" then 
        r = r..type..data.file.."★"..level.." "
    elseif item == "书" or item == "花" then
        r = r..type..data.file..level.." "
    else
        r = r..file.." "
    end
    if number == "0" or not (number or data.default) then
        return r
    end
    return r..(number or data.default)..(data.after or "")
end

return p