模組:Class
外观
local list = mw.loadData('Module:Class/data')
local getArgs = require('Module:Arguments').getArgs
local function makeInvokeFunc(funcName)
return function (frame)
local args = getArgs(frame)
return p[funcName](args)
end
end
local function isThisIdx(idx, text)
text = string.lower(text)
if text == list[idx].code then
return true
end
if text == list[idx].name then
return true
end
for i, v in ipairs(list[idx].alias) do
if text == v then return true end
end
end
p = {}
p.colour = makeInvokeFunc('_colour')
function p._colour(args)
local text = args[1]
for idx, v in inpairs(list) do
if isThisIdx(idx, text) then
return v.color
end
end
return list[#list].color
end
return p