variable_get_hash

This function returns a hash for the given variable name. This hash can be used with the struct_get_from_hash and struct_set_from_hash functions.

Accessing a variable through a hash allows for faster access when using a string, compared to using the struct[$ "string"] syntax.

 

Syntax:

variable_get_hash(name);

ArgumentTypeDescription
nameStringThe name of the variable to get the hash from

 

Returns:

Real

 

Example:

var _the_struct = {a: 77, b: 88, c: 99};
var _hash = variable_get_hash("a");
var _value = struct_get_from_hash(_the_struct, _hash);

The above code creates a temporary struct _the_struct with three member variables: a, b and c. It then gets the hash of a variable a. This hash is then used in struct_get_from_hash to retrieve the value of the struct member with the corresponding name. The returned value is assigned to another temporary variable _value.