How do I load like 100's of files the best way?

Get help using Construct 2

Post » Fri Mar 03, 2017 6:13 pm

Hello.

I am using json files of TMX importer to make levels and I use AJAX to load into game, I am loading into array. That's fine.

But the events is not ideal to load.

I tried to put into loop but it won't work because "On xxxx Completed" has this Green arrow meaning it can't be put into a loop. So I have now 21 indiviual "On xxxx completed" events and I have to manually add for every file I add to the project folder.

Same thing can be said for the "Request xxxx (tag xxxx)" long list and the the name can't be part of loop/variable because of it is from a fixed list of names of the files you have in project.

To illustrate what I mean.

Image
Image

Can I streamline this a bit? Or maybe make it automated by finding all the json files in a folder and load those in ordered manner to array?
B
58
S
18
G
13
Posts: 447
Reputation: 10,735

Post » Fri Mar 03, 2017 6:21 pm

Save all those to a dictionary, download that as json, and load it via ajax.
Image ImageImage
B
168
S
50
G
169
Posts: 8,283
Reputation: 108,195

Post » Fri Mar 03, 2017 6:36 pm

Hmm, ok thanks I will have to dig into that.
B
58
S
18
G
13
Posts: 447
Reputation: 10,735

Post » Fri Mar 03, 2017 6:44 pm

just a thought..

Image
Image
B
65
S
23
G
7
Posts: 1,502
Reputation: 10,890

Post » Fri Mar 03, 2017 7:08 pm

ajax and json aside (of which i know nothing, so maybe the following makes no sense at all) rather than trigger a different event on each level finished, you could set a function:

Code: Select all
On any level completed ---> trigger f(x)
/*where X is the current level's number*/

on f(x) triggered ---> set array value X to ajax.lastData

B
23
S
11
G
6
Posts: 181
Reputation: 5,003

Post » Fri Mar 03, 2017 7:10 pm

Thank you.
B
58
S
18
G
13
Posts: 447
Reputation: 10,735

Post » Sat Mar 04, 2017 8:59 pm

@korbaach
I have used your example with some modifications and it works! Thanks.
B
58
S
18
G
13
Posts: 447
Reputation: 10,735

Post » Sat Mar 04, 2017 9:40 pm

Hey guys. In relation to this, how do I save other sprites' instances and their respective placements per level?

What if I have multiple instances of a specific enemy in level 40 and 0 instances in level 1 or something?
Image Image Image
B
29
S
11
G
27
Posts: 730
Reputation: 17,002

Post » Sun Mar 05, 2017 8:56 am

Use a dictionary to store indexes/lists of level objects, with another subset for X/Y? Save in-game values found upon exiting and saving to the dictionary. Then just restore them back upon reloading the game.
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
51
S
24
G
30
Posts: 520
Reputation: 19,590


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests