data_get_var - ryzom/ryzomcore GitHub Wiki


title: Data Get Var description: published: true date: 2023-03-14T02:55:39.060Z tags: editor: markdown dateCreated: 2023-03-14T02:55:39.060Z

dataGetVar

The dataGetVar native AI script function is used to retrieve the content of a script data variable.

Syntax

(value: s)dataGetVar(name: s) // dataGetVar_s_s
(value: f)dataGetVar(name: s) // dataGetVar_s_f

Arguments

  • name (string): The name of the data variable to retrieve. The name is composed of a file name and a variable name separated with ':', like in "file:variable".

Return values

  • value (string or float): The content of the data variable, optionally converted to float.

Examples

($state)dataGetVar("Fyros:Patrol1State");

This example code calls the dataGetVar function to retrieve the content of the "Patrol1State" variable in the "Fyros" file. The content is stored in the $state variable as a string.

(nbPatrol)dataGetVar("Fyros:PatrolCount");

This example code calls the dataGetVar function to retrieve the content of the "PatrolCount" variable in the "Fyros" file. The content is stored in the nbPatrol variable as a float.

Notes

If the specified variable does not exist or cannot be retrieved for any other reason, a warning will be printed in the logs and an empty string or 0 will be returned.

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