Module:EC

-- -- LUA script to get Currency Icon -- -- Parameters: -- 1: Currency = (Currency,count) --             count is optional --             multiple separated by "!" (exclamation mark) -- 2: Include Name/Text Link (Optional) --             N = Currency Name --             E = "Event Currency" --             T = Alternate Text -- 3: Alternate Text (Optional) -- 4: Icon or Image (Optional) --             Display Image file if present -- 5: Size in pixels (Optional) --             for Icon default 22 --             for Image default 50 -- -- The list of available currency is kept in the module data -- -- Unknown Currency is returned if Currency Type is not in data. --

local p = {}

local currencyData = mw.loadData( 'Module:EC/data' )

function p.getEC(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 currency = tArgs[1] or "" local inclName = tArgs[2] or "" local altText = tArgs[3] or "" local imgType = tArgs[4] or "" local size    = tArgs[5]

if not size or size == "" then size = "22" if imgType ~= "" then size = "50" end end

local imgSize = ".png|x" .. size .. "px|"

if imgType ~= "" then imgType = "F" else imgType = "I" end

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

local currencyFileAll = "" local space = ""

for cur in mw.text.gsplit(currency, "%s*!%s*") do

local cName, count = mw.ustring.match(cur,                            "^([^,]-)%s*,*%s*([\/%d]*)$")

if not cName then cName = cur end

local imageFile = "work_in_progress"       local imageLink = cName .. "" local nameText = ""

if currencyData[cName] then if currencyData[cName][imgType] then imageFile = "[[File:"                           .. mw.ustring.gsub(currencyData[cName][imgType], " ", "_")            end

if currencyData[cName]["N"] then nameText = currencyData[cName]["N"] imageLink = nameText .. "|link=" .. nameText .. "]]"           end end

local nameLink = ""

if mw.ustring.match(inclName, "^[NET]$") then if nameText ~= "" then nameLink = "[[" .. nameText           else                nameLink = "[[Work In Progress"            end

if inclName == "E" then nameLink = nameLink .. "|Event Currency" elseif inclName == "T" then if altText ~= "" then nameLink = nameLink .. "|" .. altText end end nameLink = nameLink .. "]] ("       end

currencyFileAll = currencyFileAll .. space .. nameLink .. imageFile .. imgSize .. imageLink

if nameLink ~= "" then currencyFileAll = currencyFileAll .. ")"       end

if count and count ~= "" then currencyFileAll = currencyFileAll .. "'''" .. count .. "'''"       end

space = " " end return currencyFileAll end

return p