置顶公告:【置顶】关于临时开启评论区所有功能的公告(2022.10.22) | 【置顶】关于本站Widget恢复使用的公告
  • 你好~!欢迎来到萌娘百科镜像站!如需查看或编辑,请联系本站管理员注册账号。
  • 本镜像站和其他萌娘百科的镜像站无关,请注意分别。

Module:Sandbox/Leranjun/MinecraftSkin

猛汉♂百科,万男皆可猛的百科全书!转载请标注来源页面的网页链接,并声明引自猛汉百科。内容不可商用。
跳到导航 跳到搜索
Template-info.svg 模块文档  [查看] [编辑] [历史] [刷新]

{{MinecraftSkin/Auto}}的另一种实现方式。

模板代码在User:Leranjun/archive/MinecraftSkin

local p = {}
 
function p.main(frame)
    -- Frames per second: 24
    local FPS = tonumber(frame.args.FPS)
    -- Animation duration: 1s
    local DUR = 1
    -- Initial delay (for loading): 1.5s
    local DEL = 1.5
 
    -- <img src="https://render.namemc.com/skin/3d/body.png?skin={{{skin}}}&model={{{model}}}&theta={{{theta}}}&phi={{{phi}}}&time={{{time}}}&width={{{width}}}&height={{{height}}}"/>
 
    local skin = tostring(frame.args.skin)
    local model = tostring(frame.args.model)
    local theta = tostring(frame.args.theta)
    local phi = tostring(frame.args.phi)
    local width = tostring(frame.args.width)
    local height = tostring(frame.args.height)
 
    if (width == "") then
        if (height == "") then
            width = "40"
            height = "80"
        else
            width = tostring(tonumber(height) / 2)
        end
    else
        if (height == "") then
            height = tostring(tonumber(width) * 2)
        end
    end
 
    local r =
        mw.html.create("div"):addClass("lr-mc"):css("width", width .. "px"):css("height", height .. "px"):css(
        "pointer-events",
        "none"
    ):css("user-select", "none")
 
    for timee = 1, 360, (360 / FPS / DUR) do
        local imgSrc =
            string.format(
            "https://render.namemc.com/skin/3d/body.png?skin=%s&model=%s&theta=%s&phi=%s&time=%s&width=%s&height=%s",
            skin,
            model,
            theta,
            phi,
            timee,
            width,
            height
        )
        local imgDelay = tostring(DEL + (1 / FPS) * ((timee - 1) / (360 / FPS / DUR))) .. "s"
        local curImg = mw.html.create("img"):attr("src", imgSrc)
        local imgWrapper = mw.html.create("div"):css("animation-delay", imgDelay):node(tostring(curImg))
        r:node(tostring(imgWrapper))
    end
 
    return tostring(r)
end
 
return p