|instance_id||The unique ID value of the instance to use|
|name||The name of the variable to get (as a string)|
Returns: Value (any data type) or undefined (if the named variable does not exist)
With this function you can get the value from a given named variable. You supply the unique instance ID value (which can be found from the room editor, or is returned when you call the function instance_create) as well as the name of the variable to get the value of as a string (see example code below). The function will return the value held by the variable.
IMPORTANT! If the variable you are getting does not exist then the function will return the keyword undefined and you may get errors that will stop the game from functioning, so if in doubt use the function variable_instance_exists first.
if variable_instance_exists(id, "shields")
var ss = variable_instance_get(id, "shields");
var ss = -1;
The above code will check to see if a variable exists and if it does then the value it holds is retrieved and stored in a local variable. If it does not exist, the local variable is set to -1.