FANDOM


local AC = {}
 
local ageData = mw.loadData ( 'Module:Autocat/Age' )
 
local alignmentData = mw.loadData( 'Module:Autocat/Alignments' )
 
local eyeData = mw.loadData( 'Module:Autocat/Eyes' )
 
local genderData = mw.loadData( 'Module:Autocat/Gender' )
 
local hairData = mw.loadData( 'Module:Autocat/Hair' )
 
local sexualityData = mw.loadData( 'Module:Autocat/Sexuality' )
 
function AC.username(frame)
   local iusername = frame.args[1] or frame.args["iusername"]
   test = frame.args["test"]
 
    if test == "" then
        if string.lower(iusername) == "npc" or iusername == "" then
		    ousername = "[[Category:NPC]]"
	    else
		    ousername = "[[Category:"..iusername.."]]"
		    ousername2 = "Owned by [[User:"..iusername.."|"..iusername.."]]"
	    end
	end
    return ousername, ousername2
end
 
function AC.age(frame)
    local iage = frame.args[1] or frame.args["iage"]
    if tonumber(iage) ~= nil then
        oage = string.match( iage, "%d?%d?%d")
    else
        oage = string.lower(iage)
        oage = ageData[oage] or ""
    end;
    oage2 = "[[Category:"..oage.." years old]]"
    oage3 = " "..iage..""
    return oage2, oage3
end
 
function AC.sexuality(frame)
    local isexuality = frame.args[1] or frame.args["isexuality"]
    local osexuality = string.lower(isexuality)
    test = frame.args["test"]
 
    if test == "" then
        osexuality2 = sexualitytData[osexuality] or sexualitytData["#default"] or ""
        osexuality3 = isexuality
    end
    return osexuality2, osexuality3
end
 
function AC.element(frame)
    local ielement = frame.args[1] or frame.args["ielement"]
    test = frame.args["test"]
 
    if test == "" then
        oelement = string.match( string.lower(ielement), "air")
        if oelement == "air" then
            oelement2 = "[[Category:Air-Bender]]"
            oelement3 = " Airbender"
        end
        oelement = string.match( string.lower(ielement), "avatar")
        if oelement == "avatar" then
            oelement2 = "[[Category:Air-Bender]][[Category:Earth-Bender]][[Category:Fire-Bender]][[Category:Water-Bender]]"
            oelement3 = " All five bending arts"
        end
        oelement = string.match( string.lower(ielement), "earth")
        if oelement == "earth" then
            oelement2 = "[[Category:Earth-Bender]]"
            oelement3 = " Earthbender"
        end
        oelement = string.match( string.lower(ielement), "fire")
        if oelement == "fire" then
            oelement2 = "[[Category:Fire-Bender]]"
            oelement3 = " Firebender"
        end
        oelement = string.match( string.lower(ielement), "non")
        if oelement == "non" then
            oelement2 = "[[Category:Nonbender]]"
            oelement3 = " Nonbender"
        end
        oelement = string.match( string.lower(ielement), "water")
        if oelement == "water" then
            oelement2 = "[[Category:Water-Bender]]"
            oelement3 = " Waterbender"
        end
    end
    return oelement2, oelement3
end
 
function AC.height(frame)
    local iheight = frame.args[1] or frame.args["iheight"]
    local oheight = string.match( iheight, "%d'%d%d?")
    local oheight2 = string.match( oheight, "^%d")
    local oheight3 = string.match( oheight, "%d%d?$")
    test = frame.args["test"]
 
    if test == "" then
        if tonumber(oheight3) < 12 then
            oheight4 = "[[Category:"..oheight2.."'"..oheight3.."]]"
        end
    end
    return oheight4
end
 
function AC.alignment(frame)
    local ialignment = frame.args[1] or frame.args["ialignment"]
    local oalignment = string.lower(ialignment)
    test = frame.args["test"]
 
    if test == "" then
        oalignment2 = alignmentData[oalignment] or ""
        oalignment3 = "[[Category:"..oalignment2.."]]"
    end
    if not (oalignment3 == "[[Category:]]") then
        return oalignment3
    end
end
 
function AC.hair(frame)
    local ihair = frame.args[1] or frame.args["ihair"]
    local ohair = string.lower(ihair)
    test = frame.args["test"]
 
    if test == "" then
        ohair2 = hairData[ohair] or ""
        ohair3 = "[[Category:"..ohair2.."]]"
    end
    if not (ohair3 == "[[Category:]]") then
        return ohair3
    end
end
 
function AC.eyes(frame)
    local ieyes = frame.args[1] or frame.args["ieyes"]
    local oeyes = string.lower(ieyes)
    test = frame.args["test"]
 
    if test == "" then
        oeyes2 = eyeData[oeyes] or ""
        oeyes3 = "[[Category:"..oeyes2.."]]"
    end
    if not (oeyes3 == "[[Category:]]") then
        return oeyes3
    end
end
 
function AC.sexuality(frame)
    local isexuality = frame.args[1] or frame.args["isexuality"]
    local osexuality = string.lower(isexuality)
    test = frame.args["test"]
 
    if test == "" then
       osexuality2 = sexualityData[osexuality] or ""
       osexuality3 = "[[Category:"..osexuality2.."]]"
    end
    if not (osexuality3 == "[[Category:]]") then
        return osexuality3
    end
end
 
function AC.gender(frame)
    local igender = frame.args[1] or frame.args["igender"]
    local ogender = string.lower(igender)
    test = frame.args["test"]
 
    if test == "" then
       ogender2 = genderData[ogender] or ""
       ogender3 = "[[Category:"..ogender2.."]]"
    end
    if not (ogender3 == "[[Category:]]") then
        return ogender3
    end
end
 
return AC
--[[Category:Lua Modules]]