switch_actions - ryzom/ryzomcore GitHub Wiki


title: Switch Actions description: Execute a child action selected by a variable value published: true date: 2026-03-14T00:00:00.000Z tags: editor: markdown dateCreated: 2026-03-14T00:00:00.000Z

switch_actions

This action type is not exposed in the World Editor dropdown. It can be used programmatically. {.is-info}

The switch_actions action works like a switch/case statement. It reads the value of a group variable and executes the child sub-action whose label matches that value. If no label matches, a default action is executed (if one is defined).

Parameter Syntax

There are two modes:

Index mode (no labels)

<variable>

The variable value is used directly as the zero-based index into the list of child sub-actions.

Label mode

<variable> <label_0> <label_1> ... [default]

Each child sub-action is assigned a label. The variable value is compared against the labels, and the matching sub-action is executed. Use default as a label for the fallback action.

Parameters

  • <variable>: The name of the group variable to read. The value is converted to an unsigned integer.
  • <label_N> (optional): Integer labels for each child sub-action, or default for the fallback.

Sub-actions

Child sub-actions are matched to labels in order. In index mode, the variable value selects the sub-action by position (0 = first, 1 = second, etc.). In label mode, labels are matched against the variable value.

Example

With parameters myState 0 1 2 default and four child sub-actions:

  • If myState is 0, the first child executes
  • If myState is 1, the second child executes
  • If myState is 2, the third child executes
  • For any other value, the fourth child (default) executes

See also

Source: ryzom/server/src/ai_service/generic_logic_action.cpp (line 2226)

⚠️ **GitHub.com Fallback** ⚠️