打开主菜单
首页
随机
登录
设置
关于Arcaea中文维基
免责声明
搜索
查看“Module:Sandbox/SongLink”的源代码
←
Module:Sandbox/SongLink
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
local p = {} local getArgs = require('Module:Arguments').getArgs local songList = require("Module:LoadJson").Songlist()["songs"] local l = { ["#1f1e33"] = "#1f1e33", ["AI[UE]OON"] = "AI[UE]OON", ["Last | Eternity"] = "Last", ["Last | Moment"] = "Last" } local n = { ["Last | Eternity"] = "Last \| Eternity", ["Last | Moment"] = "Last \| Moment" } function p.fixLink(name) if l[name] then return l[name] else return name end end function p.fixDisplay(name) if n[name] then return n[name] else return name end end function p.link(frame) local args = getArgs(frame) local songName = args[1] -- 既可以是 id,也可以是曲名,甚至是 Beyond 曲名 local isBeyond = args[2] if (isBeyond == "") or (isBeyond == nil) then isBeyond = false else isBeyond = true end local song = nil local hasBeyondSpecialName = false for i,k in pairs(songList) do if k.id == songName then song = k break end if k.title_localized.en == songName then song = k break end if k.difficulties[4] and k.difficulties[4].title_localized and k.difficulties[4].title_localized.en == songName then hasBeyondSpecialName = true isBeyond = true song = k end end if not song then error("未找到歌曲") end if isBeyond and (not song.difficulties[4]) then error("曲目没有 Beyond 难度") end if isBeyond and song.difficulties[4].title_localized then hasBeyondSpecialName = true end local linkTo = p.fixLink(song.title_localized.en) local display = song.title_localized.en if hasBeyondSpecialName then display = song.difficulties[4].title_localized.en end local display_fixed = p.fixDisplay(display) local function fixTooltip(innerText, tooltip) if not tooltip then return "<span title=\"" .. innerText .."\">" .. innerText .. "</span>" else return "<span title=\"" .. tooltip .."\">" .. innerText .. "</span>" end end if not(display == linkTo) then if not (display_fixed == display) then display = fixTooltip(display_fixed, display) else display = fixTooltip(display) end end if not(linkTo == display) then return "[[" .. linkTo .. "|" .. display .. "]]" else return "[[" .. linkTo .. "]]" end end return p
本页使用的模板:
Module:Sandbox/SongLink/doc
(
查看源代码
)
返回
Module:Sandbox/SongLink
。