Random Chance Button App, help

Field305Field305 Member Posts: 29
edited November -1 in Working with GS (Mac)
OK well im trying to make a simple app with a little complexity. I have a button that once pushed will "change scene". What I am trying to do is make it a 1/6 chance of getting the right one to make it "change scene".

After you hit the button, I would like it to have a 2/6 chance of getting the right one and so forth. Can anyone help me with this. Thanks all!

Comments

  • hackmodfordhackmodford Member Posts: 48
    Do it like this...
    Create an attribute (I'll call it "chance") (set chance to 1 not 0)
    and another one called result

    When I push the button
    set result to "rand(chance,6)
    set chance to chance+1

    so when you start it will be random 1-6
    Next time you press it will be 2-6

    Then create another rule that detects result
    If result = 6
    Then blah blah blah
    set result to 0 (to reset the button essentially)

    I'm not sure if this works out as 1/6 2/6 3/6 but you can do something similar to this to get the effect you want.
  • hackmodfordhackmodford Member Posts: 48
    Or another way is you could have the second rule...

    If result is <= to chance
    blah blah blah
    set result to 7 (to reset the button)

    That way the first time you press it if you get 1 randomly it will be fine
    If you get 1 or 2 the second time it will work
    If you get 1 2 or 3 the third time etc.
  • Field305Field305 Member Posts: 29
    thanks guys this forum is awesome, took only 15min for 2 answers, THANK YOU!!!!!
  • Field305Field305 Member Posts: 29
    hackmodford, Im still have trouble doing this. I followed your example step by step with no luck. I have 2 questions that might solve my problem.

    1. What kind of Attributes should they be, REal, integer, boolean???

    2. After the second rule I put my "change scene" action. where should i put this?

    3. Should the attribute "result" be put to 1 also?

    Thanks for the help!!
  • Field305Field305 Member Posts: 29
    Still cant figure this out, can someone please help me!
Sign In or Register to comment.