How do i use arrays?

Get help using Construct 2

Post » Sat Jun 21, 2014 1:29 am

Really the trick for loop is cleaver. Nice to learn about tokencount and tokenat.
B
15
S
2
Posts: 5
Reputation: 984

Post » Mon May 15, 2017 3:53 pm

Hod do I load a JSON (or XML/CSV) file's data into an array? I inserted an array object and gave it dimensions of 21,1000,1 - my JSON file has 21 columns and 1001 rows - with 1 row header. Do I need a For Loop to read each object pair in JSON and set it to an x,y,z in the Array? Or can I just cut and paste the entire JSON string into the JSON load field? Or do I load it as a file? Manual doesn't really help. thanks in advance
B
4
Posts: 2
Reputation: 204

Post » Mon May 15, 2017 7:49 pm

@RealMagisterLudi

I use this for loading json files to arrays:

Add the AJAX object to your project.
Create yourArray object.
Add your.json file to your project files.

1) System| On (trigger): AJAX| Request your.json file (tag "your")

2) AJAX| On "your" completed: yourArray| Load from JSON string AJAXLastData

Make sure your json file is formatted like so for a 3D array:

{
"c2array":true,
"size":[2,3,4],
"data":[

[
[,,,],
[,,,],
[,,,]
],

[
[,,,],
[,,,],
[,,,]
]
]
}
Last edited by mekonbekon on Wed May 17, 2017 9:12 am, edited 1 time in total.
B
19
S
8
G
3
Posts: 432
Reputation: 3,978

Post » Wed May 17, 2017 3:32 am

Thanks - I'll try that tonight
B
4
Posts: 2
Reputation: 204

Previous

Return to How do I....?

Who is online

Users browsing this forum: Cub3D, David181, yiuyiu6666 and 20 guests