Detecting when an attribute changes value within a rule that is already true

tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
I know other people have figured this out before but I think they've used a different method. I've always found it hard to get this working until I thought of the way a metronome works and applied that.

The idea is that normally when you set a rule condition such as game.count > 5, the rule will trigger (run) when game.count is 6 but not ever again as game.count increases to 7, 8, etc., unless of course game.count goes below 6 again first.

This demo allows you to set up a rule condition so that any time game.count increases after the first time it reached 6, it will trigger a rule.

Also posted in Spare Code at http://forums.gamesalad.com/discussion/comment/449558/#Comment_449558

New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited February 2014
    Click the square to increase the count.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • GS_MasterGS_Master Member Posts: 159
    Awesome!
  • GameLabs222GameLabs222 Member Posts: 197
    edited February 2014
    Sweet.

    I was actually wondering if you could use something like this to prevent a value from constantly checking.

    I have a menu system in which I want to select on release to move to another set of menu options. However, using on release (with (value+1)%2 to toggle off and on) the loop never ends because release is always true somehow. I've tried fading it out after release, then adding when alpha=1 to only make it selectable then. But if you press the back button and soon as it fades back in, it triggers it again and goes back to the options menu. Pressed solves the problem, but release just feels more natural in terms of my animation and menu set up.

    Not trying to jack your thread btw :P
  • mataruamatarua Auckland, New ZealandMember Posts: 854
    Nice one will check this out and really nice to know how you came to the answer using a real world mechanical device as inspiration :)
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @Brenton222 This is a common problem with GameSalad rule conditions. It requires an extra condition. This demo I made may help you sort it out.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.