Task (functions): Difference between revisions

From PMDOWiki
Imbion (talk | contribs)
Created page with "{{Cleanup}} == TASK:StartEntityTask(RogueEssence.Ground.GroundEntity,NLua.LuaFunction) == 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. === Arguments === * <code>ent</code>: Entity which will run the task. * <code>fn</code>: Task coroutine. == TASK:StopEntityTask(RogueEssence.Ground.GroundE..."
 
Imbion (talk | contribs)
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{Cleanup}}
{{Hat Note|More functions: [[Script Reference]]''}}
== TASK:StartEntityTask(RogueEssence.Ground.GroundEntity,NLua.LuaFunction) ==


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!


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.
Tasks are run interlocked with the script processing and game processing, and characters cannot run multiple tasks at the same time.


{{FuncUsage|nmspace=TASK|nm=StartEntityTask|args=entity, coro}}


=== Arguments ===
=== Arguments ===


* <code>ent</code>: Entity which will run the task.
{| class="wikitable"
* <code>fn</code>: Task coroutine.
{{ArgHeader}}
 
{{ArgRow
== TASK:StopEntityTask(RogueEssence.Ground.GroundEntity) ==
|name=entity
 
|type=Ground Entity
|techt=RogueEssence.Ground.GroundEntity
|purp=Entity which will run the task.
}}
{{ArgRow
|name=coro
|type=Lua Function
|techt=NLua.LuaFunction
|purp=Task coroutine.
}}
|}


Helper function to force stop an entity's current task.
== StopEntityTask ==


Helper function to force stop an entity's current task. {{FuncUsage|nmspace=TASK|nm=StopEntityTask|args=entity}}


=== Arguments ===
=== Arguments ===
{| class="wikitable"
{{ArgHeader}}
{{ArgRow
|name=entity
|type=Ground Entity
|techt=RogueEssence.Ground.GroundEntity
|purp=Entity running the task to stop.
}}
|}


* <code>ent</code>: Entity running the task to stop.
== WaitStartEntityTask ==
 
== TASK:WaitStartEntityTask ==
 
 
Makes an entity run a specified task, and waits for it to complete.


Makes an entity run a specified task, and waits for it to complete before continuing.{{FuncUsage|nmspace=TASK|nm=StartEntityTask|args=entity, coro}}


=== Arguments ===
=== Arguments ===
 
{| class="wikitable"
* <code>ent</code>: Entity which will run the task.
{{ArgHeader}}
* <code>fn</code>: Task coroutine.
{{ArgRow
|name=entity
|type=Ground Entity
|techt=RogueEssence.Ground.GroundEntity
|purp=Entity which will run the task.
}}
{{ArgRow
|name=coro
|type=Lua Function
|techt=NLua.LuaFunction
|purp=Task coroutine.
}}
|}


=== Example ===
=== Example ===


<pre>
{{SectStub}}
 
TODO
 
</pre>
 
== TASK:WaitEntityTask ==
 


Waits for the specified entity to finish its task.
== WaitEntityTask ==


Waits for the specified entity to finish its task. {{FuncUsage|nmspace=TASK|nm=WaitEntityTask|args=entity}}


=== Arguments ===
=== Arguments ===
 
{| class="wikitable"
* <code>ent</code>: Entity which task we'll wait on.
{{ArgHeader}}
 
{{ArgRow
|name=entity
|type=Ground Entity
|techt=RogueEssence.Ground.GroundEntity
|purp=Entity running the task to stop.
}}
|}
=== Example ===
=== Example ===
<pre>
<pre>


Line 60: Line 89:
</pre>
</pre>


== TASK:WaitTask ==
== 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.


Runs a task and waits for it to complete. Most methods that do not expose themselves to script need to be wrapped with this. {{FuncUsage|nmspace=TASK|nm=WaitTask|args=task}}


=== Arguments ===
=== Arguments ===
 
{| class="wikitable"
* <code>obj</code>: The task to wait on.
{{ArgHeader}}
{{ArgRow
|name=task
|type=(undocumented)
|techt=(undocumented)
|purp=The task to wait on.
}}
|}


=== Example ===
=== Example ===
Line 79: Line 112:
</pre>
</pre>


== TASK:StartScriptLocalCoroutine(NLua.LuaFunction,System.Object[]) ==
== 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.


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. {{FuncUsage|nmspace=TASK|nm=StartScriptLocalCoroutine|args=fn, args}}


=== Arguments ===
=== Arguments ===
{| class="wikitable"
{{ArgHeader}}
{{ArgRow
|name=fn
|type=(undocumented)
|techt=(undocumented)
|purp=(undocumented)
}}
{{ArgRow
|name=args
|type=(undocumented)
|techt=(undocumented)
|purp=(undocumented)
}}
|}


* <code>fn</code>: None
== BranchCoroutine ==
* <code>args</code>: None
 
== TASK:BranchCoroutine(System.Object) ==
 
 
Starts a new coroutine to run parallel to the current execution.
Useful for performing multiple actions at once.


Starts a new coroutine to run parallel to the current execution. Useful for performing multiple actions at once. {{FuncUsage|nmspace=TASK|nm=BranchCoroutine|args=coro}}


=== Arguments ===
=== Arguments ===
{| class="wikitable"
{{ArgHeader}}
{{ArgRow
|name=coro
|type=Lua Object
|techt=NLua.LuaFunction,System.Object[]
|purp=The task to run in parallel. Usually is a function.
}}
|}


* <code>obj</code>: The task to run in parallel
=== Returns ===
A reference back to the task that was run to check if it was completed.


=== Example ===
=== Example ===
Line 110: Line 159:
</pre>
</pre>


== TASK:JoinCoroutines ==
== JoinCoroutines ==
 
 
Waits for all specified coroutines to finish before continuing execution.
Often used for coroutines created using TASK:BranchCoroutine()


Waits for all specified coroutines to finish before continuing execution. Often used for coroutines created using TASK:BranchCoroutine() {{FuncUsage|nmspace=TASK|nm=JoinCoroutines|args=coroTable}}


=== Arguments ===
=== Arguments ===
{| class="wikitable"
{{ArgHeader}}
{{ArgRow
|name=coroTable
|type=Table
|techt=?
|purp=A table of coroutines to wait to complete before continuing executions.
}}
|}


* <code>coroTable</code>: A table of coroutines to wait on.
* <code>coroTable</code>: A table of coroutines to wait on.

Latest revision as of 20:23, 17 January 2026

More functions: Script Reference

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

This section is a stub. You can help PMDO Wiki by expanding it.


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})