Module:Test

From Elwiki
Revision as of 23:40, 28 January 2024 by Ritsu (talk | contribs)

Documentation for this module may be created at Module:Test/doc

require('Module:CommonFunctions')
local getArgs = require('Module:Arguments').getArgs
local p = {}

function p.main(frame)
    local args = getArgs(frame);

    local CHARACTER_ID = {
        Elsword = 1,
        Aisha = 2,
        Rena = 3,
        Raven = 4,
        Eve = 5,
        Chung = 6,
        Ara = 7,
        Elesis = 8,
        Add = 9,
        LuCiel = 10,
        Rose = 11,
        Ain = 12,
        Laby = 13,
        Noah = 14,
        Lithia = 15
    }

    local lang = args.lang and ("/" .. args.lang) or ""

    local data = args[2]
    local pathIndex = ""
    local jobIndex = ""
    local transString = ""

    if data == "base" then
        jobIndex = "NO_OCCUPATION"
    elseif data ~= "base" then
        local arr = split(data, "x");
        pathIndex = arr[1] .. "LINE_"
        if string.find(pathIndex, "t") then
            transString = "_T"
            pathIndex = pathIndex:gsub("t", "")
            arr[2] = "2"
        end
        jobIndex = arr[2] and ("0" .. arr[2]) or ""
    end

    local image = mw.html.create('div'):addClass('image-cropped')
    image:tag('div'):addClass('image-wrap'):wikitext("[[File:Character Face " .. CHARACTER_ID[args[1]] .. "-FACE " .. pathIndex .. jobIndex .. transString .. ".png]]")

    return tostring(image)
end

return p