dynamic_if - ryzom/ryzomcore GitHub Wiki
title: Dynamic If description: Evaluate an AI script condition and execute a sub-action 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 is used internally by
dynamic_ifprimitive nodes, and can be used programmatically. {.is-info}
The dynamic_if action evaluates an AI script expression at runtime and executes one of its child sub-actions based on the result. Unlike condition_if which tests group variables with simple operators, dynamic_if can evaluate arbitrary AI script expressions.
The last parameter is treated as an AI script expression. At load time, it is wrapped in an if block and compiled to bytecode. On each execution, the bytecode runs in the current group's context. The result is communicated back to the action via the setConditionSuccess native function, which sets a static global flag. The action reads this flag to decide which sub-action to run.
Internally, the expression is wrapped as:
if (<expression>) { ()setConditionSuccess(1); } else { ()setConditionSuccess(0); }
<ai_script_expression>
- <ai_script_expression>: An AI script expression that evaluates to a boolean result. This can use any group variables and comparisons supported by the AI script language.
- First child action: Executed if the expression is true
- Second child action (optional): Executed if the expression is false
- Condition If: Tests a group variable with a simple comparison operator
- Condition If Else: Tests a group variable and executes one of two sub-actions
- Code: Executes a full AI script code block
Source: ryzom/server/src/ai_service/generic_logic_action.cpp (line 1515)