How do I refer to global variable names from strings

Get help using Construct 2

Post » Wed Jun 22, 2016 9:07 pm

So let's say I have global variables abc1=13, abc2=27, abc3=40.
There are also numbers called "level" and "score".

Now I want to do this: "abc"&level==score instead of this abc1==score, abc2==score, abc3==score, but it does not work.
Instead of creating 3 events, I would like create one.
It's something like playing audio directly from name.

Obviously I can (and I know how to) use arrays, but in my case it's more practical to do this from separate global variables in this case.

Inb4 I tried searching for the answer, but I couldn't find it ^^ I did not know how to formulate this question well in the google.
The creator of Gurgosus card universe!
Visit Gurgosus.eu for more info.
B
17
S
2
G
2
Posts: 47
Reputation: 1,960

Post » Wed Jun 22, 2016 9:27 pm

Use a dictionary object to contain all of your variables, instead.
A big fan of JavaScript.
B
74
S
20
G
69
Posts: 2,205
Reputation: 43,832

Post » Thu Jun 23, 2016 12:59 pm

thanks.
The creator of Gurgosus card universe!
Visit Gurgosus.eu for more info.
B
17
S
2
G
2
Posts: 47
Reputation: 1,960

Post » Thu Jun 23, 2016 1:10 pm

No probs. The great thing about the dictionary object is you can save everything as JSON for game saves etc, as well as parsing through a sequence of variables as you describe. Using containers, you can give a dictionary object to each object/actor in your game....
A big fan of JavaScript.
B
74
S
20
G
69
Posts: 2,205
Reputation: 43,832


Return to How do I....?

Who is online

Users browsing this forum: R0J0hound and 8 guests