variable_instance_get_names


Description

With this function you can retrieve an array populated with the instance variable names for an instance, or the global variables for a game. When you pass in an instance ID value, each entry in the array will be a string of the variable name that corresponds to an instance scope variable that has been created in the instance. However if you pass in the keyword global, each entry in the array will be a string of the variable name that corresponds to an global scope variable.

NOTE: This function is primarily for use with Compatibility Scripts for imported projects and the converted code for Drag and Drop actions.


Syntax:

variable_instance_get_names(instance_id/global);


Arguments:

Argument Description
instance_id/global The unique ID value of the instance to check or the keyword global

Returns:

Array (each entry is a string)


Example:

var str = "";
var array = variable_instance_get_names(id);
show_debug_message("Variables for " + object_get_name(object_index) + string(id));
for (var i = 0; i < array_length_1D(array); i++;)
    {
    str = array[i] + ":" + string(variable_instance_get(id, array[i]));
    show_debug_message(str);
    }

The above code will retrieve an array of all instance scope variables for the instance running the code block and then display these along with their values in the debug output.