CommandHelper

CommandHelper

46.5k Downloads

3+ dimensional array deep cloning fails

LadyCailinBot opened this issue ยท 2 comments

commented

CMDHELPER-3054 - Reported by PseudoKnight

@a = array(array(array(0))); 
@b = @a[]; 
@b[0][0][0] = 1; 
msg(@a[0][0][0]);
# output is 1

This doesn't fail with 2 dimensional arrays.

In testing this we also discovered an issue when the array is imported. If @A was imported. Then if it was imported again in another script, sometimes it would output 1 immediately. Sometimes only a cloned array of @A would output 1, which is strange. Not sure if they're related or not.

commented

Comment by Pieter12345

This might not be a fundamental fix, but you can use this function in MethodScript to clone a multi-dimensional array properly:
http://paste.thezomg.com/16856/10572142/

commented

Comment by Pieter12345

This has been fixed in:
#287