Copy an array (or part of it) into another array.


array_copy(dest, dest_index, src, src_index, length);

Argument Description
dest The ID of the array to copy to.
dest_index The index within the array to copy to.
src The ID of the array to copy from.
src_index The index with the array to start copying from.
length The length (number of array indices) to copy.

Returns: N/A


With this function you can copy all or part of one array into another array at any position. You need to supply both the source and the destination arrays (both need to have been created previously), as well as a position within the source array to copy from and a position within the destination array to copy to. Finally you need to specify the length of the array (or the length of the part that you want) to copy. If the data being copied exceeds the length of the destination array, the array will be extended to accept the data.


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".

Back: Arrays
Next: array_equals
© Copyright YoYo Games Ltd. 2018 All Rights Reserved