Task (functions)
The task namespace is primarily for helper functions for performing tasks and co-routines.
StartEntityTask
Helper function to make an entity run the specified task. Will not replace a running task!
Tasks are run interlocked with the script processing and game processing, and characters cannot run multiple tasks at the same time.
Argument order is TASK:StartEntityTask(entity, coro).
Arguments
| Name | Type | Technical Type | Purpose |
|---|---|---|---|
| entity | Ground Entity | RogueEssence.Ground.GroundEntity
|
Entity which will run the task. |
| coro | Lua Function | NLua.LuaFunction
|
Task coroutine. |
StopEntityTask
Helper function to force stop an entity's current task. Argument order is TASK:StopEntityTask(entity).
Arguments
| Name | Type | Technical Type | Purpose |
|---|---|---|---|
| entity | Ground Entity | RogueEssence.Ground.GroundEntity
|
Entity running the task to stop. |
WaitStartEntityTask
Makes an entity run a specified task, and waits for it to complete before continuing.Argument order is TASK:StartEntityTask(entity, coro).
Arguments
| Name | Type | Technical Type | Purpose |
|---|---|---|---|
| entity | Ground Entity | RogueEssence.Ground.GroundEntity
|
Entity which will run the task. |
| coro | Lua Function | NLua.LuaFunction
|
Task coroutine. |
Example
WaitEntityTask
Waits for the specified entity to finish its task. Argument order is TASK:WaitEntityTask(entity).
Arguments
| Name | Type | Technical Type | Purpose |
|---|---|---|---|
| entity | Ground Entity | RogueEssence.Ground.GroundEntity
|
Entity running the task to stop. |
Example
TASK:WaitEntityTask(player)
WaitTask
Runs a task and waits for it to complete. Most methods that do not expose themselves to script need to be wrapped with this. Argument order is TASK:WaitTask(task).
Arguments
| Name | Type | Technical Type | Purpose |
|---|---|---|---|
| task | (undocumented) | (undocumented)
|
The task to wait on. |
Example
TASK:WaitTask(_DUNGEON:DropMoney(100, RogueElements.Loc(10, 10), RogueElements.Loc(10, 10)))
StartScriptLocalCoroutine
A wrapper around the StartCoroutine method of the GameManager, so lua coroutines can be executed locally to the script context. AKA, it will block the script execution while its executed. Argument order is TASK:StartScriptLocalCoroutine(fn, args).
Arguments
| Name | Type | Technical Type | Purpose |
|---|---|---|---|
| fn | (undocumented) | (undocumented)
|
(undocumented) |
| args | (undocumented) | (undocumented)
|
(undocumented) |
BranchCoroutine
Starts a new coroutine to run parallel to the current execution. Useful for performing multiple actions at once. Argument order is TASK:BranchCoroutine(coro).
Arguments
| Name | Type | Technical Type | Purpose |
|---|---|---|---|
| coro | Lua Object | NLua.LuaFunction,System.Object[]
|
The task to run in parallel. Usually is a function. |
Returns
A reference back to the task that was run to check if it was completed.
Example
local coro1 = TASK:BranchCoroutine(GAME:_FadeIn(60))
JoinCoroutines
Waits for all specified coroutines to finish before continuing execution. Often used for coroutines created using TASK:BranchCoroutine() Argument order is TASK:JoinCoroutines(coroTable).
Arguments
| Name | Type | Technical Type | Purpose |
|---|---|---|---|
| coroTable | Table | ?
|
A table of coroutines to wait to complete before continuing executions. |
coroTable: A table of coroutines to wait on.
Example
TASK:JoinCoroutines({coro1})
