How do I call a variable using a string but return the number of that variable?

0 favourites
  • 5 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • GlobalVariable called CurrentGroup:A

    Other Global Variables associated with CurrentGroup variable.










    And so on....

    I have a variable that identifies the current group, called CurrentGroup. This variable and the other variables change depending on the users. It could say B or C or D or so on.

    Each group has measuring variables. So (A or B or C)1 measure the same thing, 2 measures the same thing and so on. Because each group is different they return different numbers (as shown above).

    I started with

    Set GlobalVariable to CurrentGroup & 3. This returns A3 in a string.

    But I need it to return the number. In this case, it is 275 (which is A3 number).

    Is this possible?

  • You can use another variable and set that based on the string I guess

  • You can also use Arrays in this situation. They're global objects anyway, so you can consider they contain all your Global Variables and simply call to retrieve them.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • This seems to be a case for using dictionaries... You should look it up and consider the possibility.

    Arrays, like Sam Dimanche mentioned, would work too.

    Hope this helps...


  • I will give each a try. Thanks for the suggestions!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)