How do I check items ?

Get help using Construct 2

Post » Wed Mar 22, 2017 11:45 pm

Hi,
i would like to know if there is a way to check items in local storage in one action ?
i have a lot of items to check
thanks in advance
[img]http://www.hostingpics.net/viewer.php?id=321603items.jpg][img]http://img4.hostingpics.net/thumbs/mini_321603items.jpg[/img]
B
45
S
16
G
8
Posts: 792
Reputation: 8,306

Post » Thu Mar 23, 2017 11:49 am

Pass localstorage values to variables for comparison.

If you have a lot of them you might want to consider storing them in a Dictionary, then storing the Dictionary.AsJSON as a localstorage value - instead of storing each value independently.
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 » Sun Mar 26, 2017 12:18 am

@mrtumbles
i was thinking that is possible to do it in one action
for example > start of layout >> check items "highscore1,highscore2,highscore3 etc ..."
but it's not working
B
45
S
16
G
8
Posts: 792
Reputation: 8,306

Post » Sun Mar 26, 2017 12:23 pm

Ooooh, I see what you mean. Yes! You can use a loop, and combine it with loopindex. Eg:

On start of layout
For "values" from 1 to <However many highscores you have>
|-> Check item "highscore"&loopindex

The [&] operator allows you to build a string, and [loopindex] places the step number of the current iteration of the loop.

Bear in mind you will still need individual actions for each of the rest of the item checks, however, so I would recommend using a Dictionary to store the values, and passing the Dictionary.AsJSON only as a localstorage value.
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


Return to How do I....?

Who is online

Users browsing this forum: blue visionary, namaewayukidesu, senecaa and 10 guests