if then logic

rivetopiarivetopia Member Posts: 12
edited November -1 in Working with GS (Mac)
I can not arrange the proper nesting for the following.

I have 2 integers
menu1
menu2

I have one button that I would like to have set my integers in sequence so:

on click, if menu1 = 0, then set menu1 to 1
else
if menu 1 > 0, then set menu2 to 1

but no matter how i arrange the script, both integers at set at the same time.

Comments

  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    This is how Rules are set up.

    If the conditions aren't true, the otherwise section happens. And it is always happening either one or the other.

    So when your rules kick off, menu1 is 0 which is true, so it sets menu1 to 1. This now makes that condition false so it now it goes to the otherwise and changes menu2 to 1.

    What did you want to do with these attributes?

    You could do this.
    Rule: Event: touch(pressed)
    - Change Attribute: self.count = self.count+1

    Rule: If self.count = 1
    - Change Attribute: menu1 = 1.
    Rule: If self.count = 2
    - Change Attribute: menu2 = 1.

    This could be optimized more if I knew exactly what you wanted to do with them.
  • rivetopiarivetopia Member Posts: 12
    Brillant!, Thanks CM,
Sign In or Register to comment.