GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

if then logic

rivetopiarivetopia Posts: 12Member
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 Posts: 1,803Head Chef, Member, PRO
    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 Posts: 12Member
    Brillant!, Thanks CM,
This discussion has been closed.