Quantcast
Channel: Help! with 2.0 - Twine Forum
Viewing all articles
Browse latest Browse all 1844

Pushing 2d array into array and editing problem

$
0
0
I am pushing an 2d array into an array and trying to edit the starting array between the 2 pushes and also the ending array after the pushes. both give the same results, the effects happen to both of the arrays here is a simple code to show the problem clearly. I am trying to make a large array of characters with lots of data by having a so called template 2d array, randomizing it a bit then adding it to a large array of characters and repeating the processes.
<<set $x=[[1,2,3],[4,5,6]]>>
<<set $y=[]>>

<<set $y.push($x)>>
<<set $x[1][1]=70>>
<<set $y.push($x)>>
<<set $y[0][0][0]=9>>

<<print $y>>


prints out 9, 2, 3, 4, 70, 6, 9, 2, 3, 4, 70, 6

I am taking that this is pass by reference, but how do you pass by value then?
Not sure if this is the best way to do this, any ideas, comments are appreciated.

Thanks

Viewing all articles
Browse latest Browse all 1844

Trending Articles