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,740

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
170
S
50
G
178
Posts: 8,378
Reputation: 112,925

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,740

Post » Fri Mar 03, 2017 6:44 pm

just a thought..

Image
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

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,010

Post » Fri Mar 03, 2017 7:10 pm

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

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,740

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
32
S
12
G
27
Posts: 761
Reputation: 17,244

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: 534
Reputation: 19,620


Return to How do I....?

Who is online

Users browsing this forum: Cubeeo and 10 guests