modify_variable - ryzom/ryzomcore GitHub Wiki


title: Modify Variable description: published: true date: 2023-03-12T01:09:00.666Z tags: editor: markdown dateCreated: 2023-03-11T15:39:30.481Z

modify_variable

The modify_variable action modifies the value of one of the logic variables.

Each group comes with a set of 4 variables with IDs ranging from 0 to 3. Variables are floating point values.

Local variables are the variables of the current group, and they are expressed with a 'v' followed by the variable ID (0-3), for example: v0.

Note that foreign variables are accessible only if the group name is unique in the manager or in the world. They are expressed with the group name followed by a colon ':' and then followed by a local variable identifier (v), for example: group_1:v2.

Constant values are floating-point numerical expressions in base 10.

Parameter Syntax

<local_variable | foreign_variable> < = | + | - | * | / > <local_variable | foreign_variable | constant_value>

Parameters

  • <local_variable | foreign_variable>: Name of the local or foreign variable to modify.
  • <= | + | - | * | />: Operator to apply to the variable. The + operator acts like += in C.
  • <local_variable | foreign_variable | constant_value>: Name of the local or foreign variable, or constant value to use in the operation.

Example

This example modifies variable 3 of my_npc_group, incrementing it by 1.

my_npc_group:v3 + 1

See also

  • Condition If: A similar action that performs a conditional test on group variables and executes a sub-action if the condition is met. This action can be used in conjunction with modify_variable.
  • Code: An action that executes a block of AI script code. This action can be used for more advanced variable manipulation that cannot be achieved with modify_variable.
  • Random Select: An action that executes one of its child actions at random. This action can be useful in combination with modify_variable to create randomized behavior.
⚠️ **GitHub.com Fallback** ⚠️