The dataGetVar native AI script function retrieves the value of a persistent script data variable. These variables survive AI service restarts and are stored in a binary PDR file on disk.
(value: s)dataGetVar(name: s) // returns string
(value: f)dataGetVar(name: s) // returns float
"filename:variablename". The colon separates the file group from the variable name within that group.Variables are organized into named groups (the "file" part) and individual variables within each group. This creates a two-level namespace:
"GroupName:VariableName"
For example, "Fyros:PatrolCount" stores a variable called PatrolCount in the Fyros group. All variables in the same group are stored together internally.
This is a naming convention only — the "file" name doesn't correspond to an actual file on disk. All groups are saved together in a single PDR file per AI service instance.
Variables are automatically persistent:
ai_script_data/<ais_name>_pdr.bin in the shard save directorySee dataSave for details on the persistence mechanism.
// Read a string variable
($state)dataGetVar("Fyros:Patrol1State");
if ($state == "active") {
// patrol is active
}
// Read a numeric variable
(count)dataGetVar("Fyros:PatrolCount");
count = count + 1;
()dataSetVar("Fyros:PatrolCount", count);
Source: ryzom/server/src/ai_service/nf_static.cpp (dataGetVar_s_s, dataGetVar_s_f), ryzom/server/src/ai_service/ai_script_data_manager.cpp