How do I push a value in a 3D array?

Get help using Construct 2

Post » Wed Apr 13, 2016 7:52 pm

Hi,
I just tried to push a new value in front of an array. The array is 3 dimensional and I want to add a new value at the front of the X axis and at a specific Y and Z index.
But the Push action only uses 1 axis.
How do I use the Push function in that case?
Thanks for any help! :)
Image
B
5
S
3
Posts: 193
Reputation: 1,063

Post » Wed Apr 13, 2016 8:44 pm

Pushing a value in multidimensional arrays will always create more than one new cell. It'll create a new row/column in a 2D array, and an entirely new plane in a 3D array. The axis you choose will decide how the array is expanded... but the value you push will be duplicated in the row/column/plane thus created. What I usually do in this case is push a 0 (or blank if a string array) value on the wanted axis, and then use a "Set value at" at the cell I want to adjust.
B
75
S
31
G
27
Posts: 1,012
Reputation: 20,759

Post » Wed Apr 13, 2016 9:34 pm

Thanks for your reply!
But how do I add a value at the back of my array and at a specific Y and Z index? So for example:
Front.X, 0, 1 and the Value to add there is "Hello World!"
:)
Image
B
5
S
3
Posts: 193
Reputation: 1,063

Post » Thu Apr 14, 2016 2:29 am

Instead of using push, you could just set the size of the array to be bigger and set the value like your last post.
B
94
S
33
G
117
Posts: 5,387
Reputation: 75,335

Post » Thu Apr 14, 2016 2:36 pm

@R0j0hound,
Thanks for your reply!
I didn't get it to work like you said but I found another way to do it. I'm using a loop now that tests for an unused index of the array. If it finds one it simply sets the variables at the loopindex. :)
Thanks again!
Image
B
5
S
3
Posts: 193
Reputation: 1,063


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 7 guests