Module:LimitRoleInput
Jump to navigation
Jump to search
Documentation for this module may be created at Module:LimitRoleInput/doc
local p = {}
require('Module:StrManip')
function p.main()
local input = mw.getCurrentFrame().args[1]
--local input = "Main (aaaa), Side (asdfasdf)"
local out = ""
local table = strSplit(input,",\n")
mw.logObject(input)
local res = ""
for i,indOrig in ipairs(table) do
ind = trim(tostring(indOrig):lower():gsub("^%l", string.upper)):gsub(" -%(.*%) -","")
if not ind then
mw.log("empty")
return
elseif ind:lower():find("main") then
mw.log("Main")
role = "Main"
elseif ind:lower():find("major") then
mw.log("Main")
role = "Main"
indOrig = indOrig:gsub("Major","Main"):gsub("major","Main")
elseif ind:lower():find("side") then
mw.log("Side")
role = "Side"
elseif ind:lower():find("minor") then
mw.log("Minor")
role = "Minor"
else
mw.log("invalid input")
return "Valid values are \"Main\", \"Side\" and \"Minor\".\nSee [[Help:Guidelines#Role]]."
end
if (i > 1) then
out = out .. ", "
end
out = out .. "[[:Category:" .. role .. " Character|<span style='color:#000'>" .. indOrig .. "</span>]][[Category:" .. role .. " Character]]"
end
mw.logObject(out)
return out
end
return p