local p = {} --初始化字符串 local picoutput = "" --主函数,先要判断输入的第1个参数是否满足 --如参数1/2填写错误,则自动忽略参数3并抛出报错 function p.gauge(frame) local totalHP = tonumber(frame.args[1]) --总血条数 local remainHP = tonumber(frame.args[2]) --剩余血条数 local currentHP = frame.args[3] --当前满血血量 if 0 < totalHP and totalHP <= 11 and 0 <= remainHP and remainHP <= totalHP and currentHP ~= nil then --判断参数是否输入正确 if totalHP == 1 then return frame:preprocess("<big>{{color|green|单血条怪物无须使用本模板}}</big>") --单血条怪物特例 elseif totalHP == 11 then if remainHP == 11 then picoutput = "[[File:FGO_Break_10.png|link=]]" --11条血的特殊情况(如ORT) else for counter = 1, remainHP - 1 do picoutput = picoutput .. "[[File:FGO_Break_" .. tostring(counter) .. ".png|link=]]" --循环输出剩余血条的格子 end for counter = 1, totalHP - remainHP - 1 do picoutput = picoutput .. "[[File:FGO_Break_Empty.png|link=]]" --按照剩余血条数置空血槽 end end else for counter = 1,remainHP - 1 do picoutput = picoutput .. "[[File:FGO_Break_" .. tostring(counter) .. ".png|link=]]" --循环输出剩余血条的格子 end for counter = 1, totalHP - remainHP do picoutput = picoutput .. "[[File:FGO_Break_Empty.png|link=]]" --按照剩余血条数置空血槽 end end if tonumber(currentHP) > 0 then --检测参数3是否为0,如果为0,则同样自动忽略 picoutput = picoutput .. frame:preprocess("<b> " .. "{{formatnum:" .. currentHP .."}}" .. "</b>") return picoutput else return picoutput end else return frame:preprocess("<big>{{color|red|参数不正确,请重新输入}}</big>") --1/2参数错误时返回报错提示 end end return p