Module:CharacterToken

-- -- LUA script replacement for wikitext template -- -- t-.png -- -- -- Parameters: -- 1: Character Name -- 2: Token Type -- -- The list of available tokens is kept in the module data -- -- Unknown Token is returned if Token Type is not in data. --

local p = {}

local tokenData = mw.loadData( 'Module:CharacterToken/data' )

function p.getToken(frame)

local tArgs

if frame == mw.getCurrentFrame then fParent = frame:getParent tArgs = fParent.args

if (fParent.args[1]) then tArgs = fParent.args else tArgs = frame.args end else tArgs = frame end

local character = tArgs[1] or "" local tokenType = tArgs[2] local size = tArgs[3] or "25"

character = mw.ustring.gsub(mw.ustring.lower(character), "^%s*(.-)%s*$", "%1") or ''

--   local tokenFile = ""

local tokenFile = "[[File:t-" .. character

if tokenType then tokenFile = tokenFile .. "-" .. tokenType else tokenType = "0" end

tokenFile = tokenFile .. ".png|x" .. size .. "px|"

if tokenData[character] and tokenData[character][tokenType] then tokenFile = tokenFile .. tokenData[character][tokenType] .. " Token|link=" .. tokenData[character][tokenType]

.. " Token]]" else tokenFile = tokenFile .. "Unknown Token|link=Work In Progress]]" end

return tokenFile end

return p