How do I "Choose between global variables"

0 favourites
  • 7 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.
  • Hello friends I have the following question

    As I can implement a " Choose " expression among variables whose value is greater than or equal to 1 ?

    For example:

    My variables are P1_Score (value 3) , P2_Score ( value 0 ) , P3_Score (value 1) , P4_Score ( value 0 ) , P5_Score (value 1)

    As I can get this?

    Choose ( P1_Score , P3_Score , P5_Score )

    Greetings from Chile

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Choose picks an item random from the list.

  • How?

  • just random.

    set var choose(0,1,2,3,4,5)

    And that will set one of the values at random.

    I also use it with every X seconds.

    Every choose(1,2,3)

    And at random it will trigger at 1,2 or 3.

    Sometimes, when I want a greater chance of 1 number occurring, I do choose(1,2,2,3)

  • I understand , but I need to choose eg from the Sprites as having greater or equal to 1 variable.

  • It isn't very clear what exactly you want, but if you have sprites associated with instance variables, I would use the picking system. First, you use pick by comparison to select all the sprites that have an instance variable greater than 1, then use Pick Random Instance to randomly select one.

    If you don't have instance variables, you need to iterate over the variables and put the valid ones into an Array, then generate a random Integer between 0 and the length of the Array, then pick that variable.

  • isasaurio, what bladedpenguin describes is probably what you are looking for.

    Event

    Pick all object

    pick object by evaluate where object.var > 0

    action

    do something with the objects

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