Timer select odd/even numbers?

bluebyu25bluebyu25 Member Posts: 500
edited November -1 in Working with GS (Mac)
Can we make the timer choose, at random, a odd or even number for an event?

I.E.

Timer 1, after, 1 or 3 seconds
Timer 2, after, 2 or 4 seconds

Possible?

Comments

  • hotMagichotMagic Member, PRO Posts: 266
    Any time you want to choose even or odd, use the mod function.
    Here are some more complicated examples that will lead you to your desired effect.
    http://gamesalad.com/forums/topic.php?id=1885
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Hi bluebyu25; one way I can think of seems a bit clunky but it should work (untested):

    integer attributes scene.Time1 and scene.Time2

    Change attribute scene.Time1 to random(1,2)

    When scene.Time1 = 1
    timer After 1 second
    ---etc

    otherwise
    timer After 3 seconds
    ---etc

    And the same principal with timer 2:

    Change attribute scene.Time2 to random(1,2)

    When scene.Time2 = 1
    timer After 2 second
    ---etc

    otherwise
    timer After 4 seconds
    ---etc

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • bluebyu25bluebyu25 Member Posts: 500
    hotMagic said:
    Any time you want to choose even or odd, use the mod function.
    Here are some more complicated examples that will lead you to your desired effect.
    http://gamesalad.com/forums/topic.php?id=1885

    Very nice. Hopefully I will pick this stuff up in class when I start my CIS degree Tuesday :-)
  • bluebyu25bluebyu25 Member Posts: 500
    uptimistik said:
    Ok here is how you can implement it now:

    Create two Integer Attributes: a and d (put the default value of d to 0)

    On your timer put: Every 1 second
    Change Attribute a to a+1

    Then have a rule that says:

    When Game.d = Game.a%2
    Put Whatever action you want here. (This will give you even numbers or an action whenever there is an even second)

    When Game.d (is not equal) Game.a%2
    Put whatever action you want here (This is odd numbers)

    (Took me back to school with this one buddy)

    Nice Johnathon! I just messaged you back on facebook but saw you had it posted here. Looks like you've got me out of a pickle once more :-)
Sign In or Register to comment.