Module:Float

--[==[-- -- Lua script to get Float Information -- float: get Float data based on input parameters 1 = Float Name 3 = Event Name / IP Short Name

Unknown is returned if float is not in data. --]==]

local p = {}

---[=[ For testing remove 1 '-' from start of line local floatData = mw.loadData('Module:Float/data') --[==[]=] local floatData = { -- The Little Mermaid -- ["The Little Mermaid"] = { ["magic"] = {5, 750}, ["tlm"] = {5, 450}, }, } --]==]

local EC = require("Module:EC").getEC local icon = require("Module:CharacterAvatar").getAvatar local lte = require("Module:LTEvent").getLTE local util = require("Module:Utility")

function p.float(frame) local tArgs = util.getArgs(frame)

local floatName = tArgs[1] or "" local event = tArgs[2] or "" local outType = tArgs[3] or ""

floatName = floatName:gsub("^%s*(.-)%s*$", "%1") or '' if floatName == "" then floatName = mw.title.getCurrentTitle.text else floatName = mw.text.decode(floatName, false) end floatName = floatName:gsub("%s*Float$", "")

event = event:lower:gsub("^%s*(.-)%s*$", "%1") or '' if outType and outType == "R" then outType = "R" else outType = "D" end

local data = {}

if floatData[floatName] then data = floatData[floatName] else data = { ["magic"] = {"?", "?"}, }	   floatName = "Work In Progress|Unknown" end

local reward = ""

if event ~= "" and data[event] then reward = event else reward = "magic" -- current event (no magic entry yet) -- pick the first reward key (should be for current event) if not data["magic"] then for k, v in pairs(data) do				reward = k				break end end end if data then u = 1 for k, v in pairs(data) do			u = u + 1 end end

local tFunc = { -- Rewards only ["R"] = function local retText = "" local space = ""

if event ~= "" then for k, v in pairs(data) do							if u > 3 then eventInfo = " (" .. lte({k, nil, "K"}) .. " Event) " else eventInfo = "" end if k ~= "magic" then local tRow = { space, EC({"Gems"}), v[1], ", ", EC({k}), v[2], "", "",									eventInfo }								retText = retText .. table.concat(tRow) space = " " end end else if data[reward][1] ~= "" then local tRow = { "", EC({"Gems"}), data[reward][1], ", ", EC({reward}), data[reward][2], "", "",							}							retText = retText .. table.concat(tRow) end end return retText end, -- Default (token rewards table row) ["D"] = function local tRet = {"|-\n|", "", "\n|", "", "",									"", "", "", "", "", "", "\n|\n|", "", "\n| nowrap|", "", "", ", ", "", "",					}					tRet[ 2] = icon({"Parade", event or ""}) tRet[ 6] = floatName tRet[ 7] = " Float" if data[reward][1] ~= "" then tRet[13] = "2h" tRet[15] = EC({"Gems"}) tRet[16] = data[reward][1] tRet[18] = EC({reward}) tRet[19] = data[reward][2] else tRet[17] = "" end return table.concat(tRet) end, }	return tFunc[outType] end

return p --