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
107
S
20
G
8
Posts: 155
Reputation: 11,752

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
76
S
31
G
27
Posts: 1,016
Reputation: 20,792

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
172
S
50
G
184
Posts: 8,445
Reputation: 116,109

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
94
S
33
G
118
Posts: 5,396
Reputation: 75,853


Return to How do I....?

Who is online

Users browsing this forum: Exabot [Bot] and 37 guests