Module:Tasks

-- -- LUA script to get Task for Character Activities

-- Parameters: -- 1: Task Duration -- 2: "J" if the task is a join-task (with two characters) -- 3: Event Name -- --

local p = {} local taskData = mw.loadData( 'Module:Tasks/data' ) local EC = require ("Module:EC").getEC

function p.getData(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 joint   = 0 local duration = tArgs[1] or "" if (tArgs[2] and tArgs[2] ~= "") then joint = 2 end local ipName  = tArgs[3] or "dmk"

ipName = string.lower(ipName) duration = string.lower(duration)

local ipTaskData = taskData[ipName] if not ipTaskData then ipTaskData = taskData[string.match(ipName, "(.+)grumpy")] if not ipTaskData then ipTaskData = taskData["dmk"] end end

if duration == "all" then return "|Various\n| nowrap|" .. EC({"xp"}) .. ", "               .. EC({string.gsub(ipTaskData["name"], "^EC%-", "")}) else if not ipTaskData[duration] then duration = "?h" end return "|" .. duration .. "\n| nowrap|" .. EC({"xp"}) .. ipTaskData[duration][1 + joint] .. ", "               .. EC({string.gsub(ipTaskData["name"], "^EC%-", "")}) .. ipTaskData[duration][2 + joint] end end return p

-- --