• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

[GM:S 1.4] array_copy does not work for 2d arrays

607

Member
Hi, it's me again!

In case anyone else is wondering what they're doing wrong: nothing. array_copy does not seem to work with 2d arrays.


Code:
for (var xcor = 5; xcor >= 0; xcor--)
    for (var ycor = 8; ycor >= 0; ycor--)
        array[xcor,ycor] = "test"
    
arraycopyheight[0,0] = 0
arraycopylength[0,0] = 0
        
array_copy(arraycopyheight,0,array,0,array_height_2d(array))
array_copy(arraycopylength,0,array,0,array_length_2d(array,0))
arraycopyheight is now a one-dimensional array with 6 items and arraycopylength is now a one-dimensional array with 8 items.

I'll look for a solution (i.e. a way to copy a 2d array anyway) tomorrow.
Although, actually... come to think of it, what array_copy does is probably just something like
Code:
for (var index = array_length_1d(your_old_array); index >= 0; index--)
   your_new_array[index] = your_old_array[index]
In that case, I don't even need array_copy. :p That's something I should remember! If I'm having trouble using a built-in function (in any language), I should consider, or look up if there's documentation, how it works, and if it's not more efficient than I can program myself, I can give up on using the built-in function, perhaps.
 
Top