Multiple external files to arrays [AJAX]

Get help using Construct 2

Post » Mon Jan 23, 2017 10:02 pm

Hey guys, I've been concerned lately and would really appreciate if someone could clear something up:

I'm using AJAX to load an array (many, MANY values) from a .json file into an array object once. I also load the kerning of a custom font with it, so I'm not worried right now, but I think I'll be using this plugin for other purposes with several files in the future, loading at any time (dialog, etc...)

So the thing is: keeping in mind that loading a file isn't instant, will the expression AJAX.lastdata be conflicted when constantly loading different files?

Should I make loading a file a function that gives a signal when finished to be sure, or am I ovethinking this?

Or should I just load everything from one file (by using tokenat)? Would it be cpu-expensive?

In the end, everything ends up in arrays so, is there a hacky alternative to have loaded array objects from the beginning without using AJAX (maybe by tampering with the project files)?

Any help/info is appreciated.
B
9
S
3
Posts: 152
Reputation: 1,270

Post » Tue Jan 24, 2017 11:38 am

From the manual:

LastData
The contents of the last response. This is set in the On completed trigger. If used in a different event, it contains the response of the last completed request.


So long as you're loading the data into the Array object in the relevant 'On completed' trigger, the data will not conflict. Basically: you can use LastData outside an 'On completed' trigger, but you REALLY shouldn't.
The LEVEL GENERATOR TOOLKIT



24 functions dedicated to producing randomly generated terrain for all kinds of games.
B
25
S
7
Posts: 242
Reputation: 2,306

Post » Tue Jan 24, 2017 6:17 pm

Thanks, I guess I'll redo some of the code to support "on complete"
B
9
S
3
Posts: 152
Reputation: 1,270


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 29 guests