data_get_var - ryzom/ryzomcore GitHub Wiki
title: Data Get Var description: published: true date: 2023-03-16T23:05:49.102Z tags: editor: markdown dateCreated: 2023-03-16T22:22:02.337Z
The dataGetVar native AI script function is used to retrieve the content of a script data variable.
(value: s)dataGetVar(name: s) // dataGetVar_s_s
(value: f)dataGetVar(name: s) // dataGetVar_s_f
- 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".
- value (string or float): The content of the data variable, optionally converted to float.
($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.
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.