[HOW?] compare random value without any variable

0 favourites
  • 5 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hello

    Today I was thinking if it was possible to compare a random value in a conditino without first setting a random value to a variable..

    normally I first add a condition that adds a random value to a variable, like random(3) (this can be 0, 1 or 2)

    then I add another condition that compare this variable result with another value of my choice and depending of the choice, a different action will be performed.

    but, is it possible to jump the part of adding a random value to a variable and instead compare directly in the condition? example:

    <CONDITION>

    SYSTEM - round(random(3)) = 2

    SYSTEM - trigger once

    <ACTION>

    set Text1.Text "It works"

    else

    set Text1.Text "Oops"

    right now if I do that, the condition will test all the possibilities of the random expression and so will always trigger the action setting the text to "It works". My question is if there is a way that the condition will only try 1 value of the random expression and then stop.

  • Ahem ... manual is here to help you !

    Second paragraph , just after general sub-title !

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Bonus usability hint: use choose(0,1,2) instead of round(random(3))

  • Ahem ... manual is here to help you !

    Second paragraph , just after general sub-title !

    Apparently you did not even read what I wrote because your answer has nothing to do with my question.

  • Bonus usability hint: use choose(0,1,2) instead of round(random(3))

    why would choose be better than round(random)? isn't the same in this case?

    I also tried to compare choose(0,1) with a value and test if it trigger 50% of the times but it always trigger an action because the condition test the 2 options(0 and 1).

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