Hyomoto
Member
I posted this as a bug but on further inspection I'm not sure where the intended versus improper behavior is so I probably should have done this first to get some feed back. When you are using nested arrays, there are some troublesome behaviors that I want to say are bugs, but maybe they are working as intended and other things are at fault. Here is a sample script that demonstrates the issue:
The output is:
You can see that only the first one works correctly when displayed with show_debug_message. The other three have varying degrees of issues. The interesting part, and the reason I ask if this is intended and where the bugs may actually be at, is what it seems to be doing is adding that variable to the array, which is itself equal to an array. If you check the value of any indice in that array, it will show up as equal to arrayValue. So, all those blank spaces you see in those declared arrays are actually equal to that variable. If you change it, they seem to change with it though as you can see in array2, this isn't always the case. So either the issue is that the arrays aren't being built correctly or the entire array isn't being properly filled with that variable pointer.
I'm fairly certain this is a bug and not the intended behavior, but I figure it's worth asking/demonstrating.
Code:
array = [ ]
for ( var _i = 0; _i < 5; _i++ ) { array[ _i ] = [ 0, 1, _i ] }
array2 = [ ];
arrayValue = [ 0, 1, 2 ];
for ( var _i = 0; _i < 5; _i++ ) {
arrayValue[ 2 ] = _i;
array2[ _i ] = arrayValue;
}
array3 = [ ];
array3 = array_create( 5, [ 0, 1, 2 ] );
array4 = [ ];
array4 = array_create( 5, arrayValue );
show_debug_message( array );
show_debug_message( array2 );
show_debug_message( array3 );
show_debug_message( array4 );
Code:
{ { { { 0,1,0 }, },{ { 0,1,1 }, },{ { 0,1,2 }, },{ { 0,1,3 }, },{ { 0,1,4 }, } }, }
{ { { { 0,1,0 }, },{ { 0,1,4 }, },{ },{ },{ } }, }
{ { { { 0,1,2 }, },{ },{ },{ },{ } }, }
{ { { { 0,1,4 }, },{ },{ },{ },{ } }, }
I'm fairly certain this is a bug and not the intended behavior, but I figure it's worth asking/demonstrating.
Last edited: