data_set_var - ryzom/ryzomcore GitHub Wiki
title: Data Set Var description: Set a persistent script data variable published: true date: 2026-03-14T00:00:00.000Z tags: editor: markdown dateCreated: 2023-03-16T22:22:10.171Z
The dataSetVar native AI script function sets the value of a persistent script data variable. These variables survive AI service restarts and are automatically saved by the Backup Service.
()dataSetVar(name: s, value: s) // set string value
()dataSetVar(name: s, value: f) // set float value-
name (string): The variable identifier in the format
"filename:variablename". See dataGetVar for details on the naming convention. - value (string or float): The value to store. Float values are converted to strings internally.
Setting a variable marks the data as dirty. The Backup Service automatically detects this and saves all variables to ai_script_data/<ais_name>_pdr.bin. You do not need to call dataSave() — persistence is automatic.
Variables are scoped to the AI service instance, not to a specific group. Any group in the same instance can read variables set by another group.
// Store a string state
()dataSetVar("Fyros:Patrol1State", "Active");// Store a counter
(count)dataGetVar("Fyros:PatrolCount");
count = count + 1;
()dataSetVar("Fyros:PatrolCount", count);// Track tribe camp state across restarts
()dataSetVar("Tribes:CampAlpha_TileCount", tileCount);
()dataSetVar("Tribes:CampAlpha_LastEvent", $eventName);- If the file group or variable doesn't exist, it is created automatically.
- Float values are converted to strings for storage, so precision may be lost for very large or very precise numbers.
- Changes are persisted asynchronously — there may be a brief delay before the Backup Service writes to disk. If the AI service crashes between
dataSetVarand the next Bsi save cycle, the most recent changes may be lost.
- dataGetVar - Read a persistent variable
- dataSave - Explicit save (no-op, persistence is automatic)
- setNelVar - Set a non-persistent runtime variable
Source: ryzom/server/src/ai_service/nf_static.cpp (dataSetVar_ss_, dataSetVar_sf_), ryzom/server/src/ai_service/ai_script_data_manager.cpp