Random even number?

IsabelleKIsabelleK Member, Sous Chef Posts: 2,807
edited November -1 in Working with GS (Mac)
Hello!
I want to create a change attribute behavior: change game.XXX to random(200,300), but I want the attribute to always be an even number (so: 200, 202, 204 etc.). Is there any way to do it?

Thank you!

Comments

  • HasifUzirHasifUzir Member Posts: 41
    What I would do is multiply the random value by 2. To get it in between the range of 200-300, just use half initially. So:

    (random(100,150))*2

    [ if 123, then 123*2 is 246]
    [ if 148, then 148*2 is 296]
    [ if 119, then 119*2 is 238]

    Hope this helps :D
  • old_kipperold_kipper Member Posts: 1,420
    you could do it with-

    (random(100,150))*2

    beat me to it..
  • IsabelleKIsabelleK Member, Sous Chef Posts: 2,807
    Thank you HasifUzir and old_kipper! It works perfect :)
  • HasifUzirHasifUzir Member Posts: 41
    I'm glad I could help :D
Sign In or Register to comment.