store sub-array inside a main array?

Get help using Construct 2

Post » Fri Sep 04, 2015 8:06 pm

@ashley, @Rojohound, @newt

Hi community,

How can i store a sub-array inside the key of a main array. In simpler words, how can i store an array inside an array?

Have been looking extensively in the forums searching for an answer, with no findings.

Many thanks in advanced...
B
106
S
20
G
8
Posts: 155
Reputation: 11,716

Post » Fri Sep 04, 2015 8:33 pm

Well, you could use JSON to store a sub-array in another one. However, you won't be able to easily access its values once stored. You would need to load it in a "temporary" array, edit it, and store it back as JSON.
B
71
S
30
G
24
Posts: 984
Reputation: 19,003

Post » Fri Sep 04, 2015 9:05 pm

You could try tokenat()
https://www.scirra.com/manual/126/system-expressions
But as Magistross pointed out it's not easy to edit.
Image ImageImage
B
169
S
50
G
173
Posts: 8,313
Reputation: 110,270

Post » Sat Sep 05, 2015 6:53 pm

You could just store the uid of one array in another. Then you'd pick the other array by uid before using it.

Or taking the idea further you could use iid's instead. Which would still require you to pick the array before setting values, but you could then get values with:
Array2(Array1.at(1,4,5)).at(4,6)
B
92
S
32
G
109
Posts: 5,290
Reputation: 70,991


Return to How do I....?

Who is online

Users browsing this forum: Artcadev, MadSpy, MaxxMunnn, Uk4dee and 30 guests