array_equals(var1, var2);
Argument | Description |
---|---|
var1 | The index of the first array. |
var2 | The index of the second array. |
Returns: Boolean
With this function you can check to see if two arrays are equal (equivalent or the same). You give the two arrays to check, and the function will return true if they are equal (either equivalent or the same) or false if they are not. Note that this is not the same as checking if two arrays are the same using ==, which will not check to see if the two arrays hold equivalent values, but only to see if the arrays are referencing the same initial array. For example:
var a = [1,2,3,4];
var b = [1,2,3,4];
if (a == b)
{
show_debug_message( "This will never fire, as a
and be do not reference the SAME array" );
}
if (array_equals(a, b))
{
show_debug_message( "This will fire now" );
}
if !array_equals(inventory_array, item_array)
{
var len = array_length_1d(inventory_array);
array_copy(item_array, 0, inventory_array, 0,
len);
}
The above code will check two arrays to see if they hold equivalent values, and if they do not then the code will copy the entire contents of the array "inventory_array" to the array "item_array".