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
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).
There are two modes:
<variable>
The variable value is used directly as the zero-based index into the list of child sub-actions.
<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.
- <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
defaultfor the fallback.
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.
With parameters myState 0 1 2 default and four child sub-actions:
- If
myStateis 0, the first child executes - If
myStateis 1, the second child executes - If
myStateis 2, the third child executes - For any other value, the fourth child (default) executes
- Condition If: Tests a variable against a single value
- Random Select: Executes a random child action
Source: ryzom/server/src/ai_service/generic_logic_action.cpp (line 2226)