weak_ref_any_alive

With this function you can check the weak reference to various structs to see if it they are still "alive" or not. You supply an array of weak references to check (each weak reference should have been created using the function weak_ref_create), and the function will return true if any of the structs are still being referenced somewhere or false if they are not and have been garbage collected. Note that if you supply an array where any of the values are not a weak references, the function will return undefined.

Note that the function also takes two optional arguments, where the first permits you to supply an initial index into the array to check from, as well as an argument to set the number of positions (length) from that index to check. If specified, only the array indices within those parameters will be checked.

 

Syntax:

weak_ref_any_alive(array, [index], [length]);

ArgumentTypeDescription
arrayArray of Struct Weak ReferencesArray containing weak references to the structs that you want to check.
indexRealOPTIONAL The index into the array to start checking from
lengthRealOPTIONAL The number of positions, starting from the given index, to check for

 

Returns:

Boolean (or undefined)

 

Example:

if weak_ref_any_alive(inventory_ref_array)
{
    instance_destroy(obj_Inventory_Control);
}

The above code checks an array of weak references and if any are still alive then an instance is destroyed.