execute
- Last UpdatedFeb 19, 2025
- 3 minute read
The execute statement enables to trigger the execution of a command or a coroutine.
-
If the invoked command or coroutine has defined no argument in the args field: the value attribute can be used to pass a list of comma separated parameters. Value can also be skipped, if command is not expecting any.
-
If the invoked command or coroutine has defined a single argument in the args field: user must specify the argument as attribute or alternatively use the value attribute. In both cases, the passed value must match the corresponding argument type.
-
If the invoked command or coroutine has defined multiple arguments in the args field: user must specify all the arguments as attributes. All passed values must match the corresponding argument type. In this case the value attribute is not used.
As good practice, all commands and coroutines that rely on passed parameters should define args.
Platform support
This node is fully supported on XR-Windows, XR-Portable Windows, XR-Portable iOS, XR-Portable Android, and XR-Portable WASM platforms.
|
XR-WIN |
XR-P-WIN |
XR-P-IOS |
XR-P-AND |
XR-P-WASM |
|---|---|---|---|---|
|
Full support |
Full support |
Full support |
Full support |
Full support |
|
|
|
|
|
|
Code example
These are code examples for the execute statement.
<!-- Invoking a command with no args defined without passing any value -->
<execute command="cmd_doJump" />
<!-- Invoking a command with no args defined passing a comma separated list of parameters -->
<execute command="cmd_doJumpTo" value="0 0 1,static" />
<!-- Invoking a command that requires a single arg -->
<execute command="cmd_doJump" value="1 1 1" />
<execute command="cmd_doJump" position="1 1 1" />
<!-- Invoking a command that requires a multiple args -->
<execute command="cmd_doJump" position="1 1 1" mode="static />
Code example
This code example shows executing an XRS method.
namespace Name
{
class Class
{
public void myMethod(string arg1, int arg2)
{
}
public static void myStaticMethod(string arg1, int arg2)
{
}
}
}
<!-- Execute an XRS Script Object method -->
<execute script="NameClassObject.myMethod" arg1="forza genoa" arg2="1893" />
<!-- Execute an XRS Static method -->
<execute script="Name::Class.myStaticMethod" arg1="forza genoa" arg2="1893" />
Fields
These are the fields for execute statement.
|
Fields |
Type |
Use |
Default |
Description |
|---|---|---|---|---|
|
argXXX |
Depends on the type declared in the invoked command args attribute |
Optional |
No default value |
If the invoked command has specified a list of args, they should be valorized in the execute statements. The same applies to XRS methods, which are invoked using script instead of command field. |
|
command |
sstring |
Mandatory |
No default value |
Defines the command or coroutine to execute. |
|
condition |
sstring |
Optional |
No default value |
Applies a condition to the function execution. |
|
script |
sstring |
Optional |
No default value |
Name of the method that need to be executed. Namespace::ClassName.MethodName |
|
useDeltaTime |
sbool |
Optional |
True |
Enables and disables the use of frame delta time as a multiplier of all movements. Disable if you want to control the movements from script by passing exact deltas in meters for fly/zoom and in radians for yaw/pitch. |
|
value |
sstring |
Optional |
No default value |
The parameters to pass to the command or coroutine. |