How do I choose from a global variable string?

0 favourites
  • 4 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • Hi guys!

    I'm a bit stuck with this one:

    I'm loading functions names from a dictionnary to a global variable, and call them into a choose action to randomly choose some fonctions.

    But for some reasons, construct seems to ignore my request, do you have any idea? every 2 sec > choose("pointYellow","pointRed"levelSelect)

    Level select is the global variable The global variable contain something like ,"pointGreen","pointPink" (with quotes and comas)

    WHY? :/

    Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Function name in the variable should not contain quotes or commas. If your variable contains a comma-separated list of function names, then you can't use it in choose() expression like that. Instead, parse it with tokenat, for example:

    Set list to "FunctionA,FunctionB,FunctionC"
    Call function tokenat(list, int(random(tokencount(list,","))), ",")
    
  • Thank you very much for the reply!

  • Just to let you know, a choose on a tokenat was the key to my problem! Thank you, I learned a lot!

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