Need Help with Rule.

QorrelQorrel Member Posts: 22
edited November -1 in Working with GS (Mac)
Hi, im trying to make a button that alternates between two integers when pressed. I have made one that should work but it doesn't, as in it works to change a variable one way but not the other. The Code so far.

-Group; (
Rule- Attribute. game.Thing. = 1
-Rule. Attribute. Angle = 270
--Rule actor on pressed - change attribute to 90

Rule- Attribute. game.Thing. = 1
-Rule. Attribute. Angle = 90
--Rule actor on pressed - change atrribute to 270
)

The only way i can get it to work is if i do it so it only stays if i make it at 270 so long as i press it.

Any suggestions?
-(oh, i changed the name of the attributes as its my key mechanic)

Comments

  • Rob2Rob2 Member Posts: 2,402
    This easy way to make a toggle or alternating switch is :-

    change attribute: game.toggle to 1-game.toggle

    and then test for game.toggle = 0 or 1 and change your other attributes accordingly.
  • QorrelQorrel Member Posts: 22
    Rob2 said:
    This easy way to make a toggle or alternating switch is :-

    change attribute: game.toggle to 1-game.toggle

    and then test for game.toggle = 0 or 1 and change your other attributes accordingly.

    Pardon?

    I think i am doing that. From what i understand i am doing. I am changing the atrribute so long as the other one is on. But for some reason that does'nt work if i have the two toggles on the touch's on "inside". When i give it on pressed and released then it works.
  • MotherHooseMotherHoose Member Posts: 2,456
    I think that if all the events and actions happen only on this actor... you should use local attributes... (self.Attribute)

    [Rule] when touch is pressed
    --[Rule] when self.Attribute = 270
    --changeAttribute self.Attribute = 90
    Otherwise
    --[Rule] when self.Attribute = 90
    --changeAttribute self.Attribute = 270

    MH
Sign In or Register to comment.