API:GetLiveEventTasks
From RoR Wiki
UI Lua API · LiveEvent functions
Version: WAR 1.4.8
Returns the tasks of a live event, the player's progress, and the reward levels.
tasks = GetLiveEventTasks(eventId)
Arguments
- eventId
number– Event id, as in GetLiveEventList.
Returns
- tasks
table– Array of the event's top-level task tables (indexed from 1), plus the named fields below. Nothing is returned if the event is unknown or inactive.
Named fields of tasks:
| Key | Type | Meaning |
|---|---|---|
overallMaxValue |
number |
– |
overallCurrentValue |
number |
The player's overall progress. The stock UI compares it with the reward level thresholds. |
eligible |
boolean |
Whether the player is eligible for the event rewards. |
rewards |
table |
Array of reward levels (see below). |
Each task table (also used for subtasks):
| Key | Type | Meaning |
|---|---|---|
taskId |
number |
Task id. |
name |
wstring |
Task name. |
maxValue |
number |
Progress needed for the task. |
currentValue |
number |
The player's progress on the task. |
isOnlyText |
boolean |
– |
tooltipText |
wstring |
Tooltip text. |
subtasks |
table |
Array of child task tables with the same layout. |
textureName |
string |
Only for tasks that have a picture: the texture name. Load the picture with SetLiveEventTaskImage before using it. |
textureRightAlign |
boolean |
Only for tasks that have a picture. |
Each reward level in rewards:
| Key | Type | Meaning |
|---|---|---|
threshold |
number |
Overall progress needed for this level. |
items |
table |
Array of item data tables for the level's reward items. |
Details
- The tasks are in the array part of the table, so loop over them with
ipairs. The stock UI also checkstype(task) == "table". - Exactly one argument must be passed.
Errors
These are written to the UI log, and the function returns nothing.
Error in function call 'GetLiveEventTasks': Event %d not found.(also for an event that exists but is inactive)
Example
From default/ea_tomeofknowledge/source/tomewindow_liveevent.lua, finding the parent of a task:
local tasksList = GetLiveEventTasks( eventId )
local function RecursiveHelper( currentTasksList, parentTaskId )
for _, task in ipairs( currentTasksList )
do
...
if ( task.taskId == taskId )
then
return true, parentTaskId
end
local didFind, foundParentTaskId = RecursiveHelper( task.subtasks, task.taskId )
...
From the same file, the reward progress bar:
levelPercent = ( LiveEventTasks.overallCurrentValue - lastLevelThreshold ) / ( LiveEventTasks.rewards[level].threshold - lastLevelThreshold )
