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

dataSetVar

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.

Syntax

()dataSetVar(name: s, value: s) // set string value
()dataSetVar(name: s, value: f) // set float value

Arguments

  • 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.

Persistence

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.

Examples

// 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);

Notes

  • 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 dataSetVar and the next Bsi save cycle, the most recent changes may be lost.

See also

  • 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

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