Module:Face: Difference between revisions
No edit summary |
No edit summary |
||
(6 intermediate revisions by the same user not shown) | |||
Line 26: | Line 26: | ||
local character = args[1] | local character = args[1] | ||
local data = args[2] | local data = args[2] | ||
local isBase = not data or data == "base"; | |||
local pathIndex = "" | local pathIndex = "" | ||
local jobIndex = "" | local jobIndex = "" | ||
local transString = "" | local transString = "" | ||
local link = args.link and ( | local link = args.link and (isBase and character or args.link) or "" | ||
local lang = args.link and args.lang and ("/" .. args.lang) or "" | local lang = args.link and args.lang and ("/" .. args.lang) or "" | ||
local scale = args.scale or 1 | local scale = args.scale or 1 | ||
local charId = string.len( | local id = CHARACTER_ID[character] | ||
local charId = string.len(id) == 1 and ("0" .. id) or id | |||
if | if isBase then | ||
jobIndex = "NO_OCCUPATION" | jobIndex = "NO_OCCUPATION" | ||
else | |||
local arr = split(data, "x"); | local arr = split(data, "x"); | ||
if not #arr then | if not #arr then | ||
Line 51: | Line 53: | ||
local image = mw.html.create('div'):addClass('image-cropped') | local image = mw.html.create('div'):addClass('image-cropped') | ||
image:tag('div'):addClass('image-wrap') | image:tag('div'):addClass('image-wrap image-face') | ||
:attr( | :attr("style", "width: " .. 116 * scale .. "px; height: " .. 60 * scale .. "px;") | ||
:wikitext("[[File:Character Face " .. charId .. "-FACE " .. pathIndex .. jobIndex .. transString .. ".png|link=" .. link .. lang .. "]]") | |||
:wikitext("[[File:Character Face " .. | |||
return tostring(image) | return tostring(image) |
Latest revision as of 01:07, 31 January 2024
Documentation for this module may be created at Module:Face/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 character = args[1]
local data = args[2]
local isBase = not data or data == "base";
local pathIndex = ""
local jobIndex = ""
local transString = ""
local link = args.link and (isBase and character or args.link) or ""
local lang = args.link and args.lang and ("/" .. args.lang) or ""
local scale = args.scale or 1
local id = CHARACTER_ID[character]
local charId = string.len(id) == 1 and ("0" .. id) or id
if isBase then
jobIndex = "NO_OCCUPATION"
else
local arr = split(data, "x");
if not #arr then
arr[1] = data
end
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 image-face')
:attr("style", "width: " .. 116 * scale .. "px; height: " .. 60 * scale .. "px;")
:wikitext("[[File:Character Face " .. charId .. "-FACE " .. pathIndex .. jobIndex .. transString .. ".png|link=" .. link .. lang .. "]]")
return tostring(image)
end
return p