persistent behaviors within rules

This is probably a simple fix, but I'm still learning GameSalad. How do you set up a rule where if the rule is met, the actor continues to do the persistent behavior even if the rule no longer applies?
Here is my problem. I want my actor to do the following: Start off not rotating. The first time someone touches it, it rotates clockwise at 90 until it is touched again. Once it has been touched to stop rotating clockwise, if it is touched again, it rotates counter-clockwise at 90 until it is touched again. Start the cycle over.
I tried setting up a boolean attribute named 'clockwise' and changing it to false the first time the actor is touched, but that just makes it stop rotating after one pixel because "actor - touch - released" and 'attribute - clockwise = true" aren't both true anymore.

Comments

  • mrpacogpmrpacogp Member Posts: 400
    You set the attribute for the actor or the game?
    test integer too
  • mnoricmnoric Member Posts: 4
    I set the attribute for the actor as I will have several different actors that each have different rules for how they rotate. I tried doing it with an integer, but ran into the same issue with the rule no longer being valid after the value was changed.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited November 2012

    @mnoric

    Hi, I'm not sure if, when you say "Start the cycle over", you mean back to stopped or not, the following assumes that it doesn't stop, but keeps flipping between clockwise and counter-clockwise, once started. If you want it to start rotating clock, then anti-clock, then stop, then clock, anti-clock, stop, etc let me know and I'll change the following rules for you.

    So try this (two boolean attributes):

    Rule: When touch is pressed
    Change Attribute scene.StartA to true
    Rule (nested in above rule) When scene.FlipA is false
    Change Attribute scene.FlipA to true
    Otherwise
    Change Attribute scene.FlipA to false

    ------

    Rule: When scene.StartA is true
    Rule (nested in above) When scene.FlipA is true
    Rotate Clockwise Speed 90
    Otherwise
    Rotate Counter-Clockwise Speed 90



    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • mnoricmnoric Member Posts: 4
    edited November 2012
    what I actually want is clock, stop, counter-clock, stop, clock, etc...
    Using your code as an example, I have:

    Rule: When touch is pressed
    Rule (nested) When self.turning is true
    Change Attribute self.turning to false
    Otherwise
    Change Attribute self.turning to true
    Rule (nested in 'when touch is pressed' level): When self.clockwise is true
    Change Attribute self.clockwise to false
    Otherwise
    Change Attribute self.clockwise to true
    ---
    Rule: When Self.turning is true
    Rule (nested): When self.clockwise is true
    Rotate Clockwise Speed 90
    Otherwise
    Rotate Counter-Clockwise Speed 90

    With that logic and with clockwise and turning both set to false at run time, the actor starts out not rotating. When you touch it, it goes back and forth between stopped and rotating clockwise. It never rotates counter-clockwise.
  • mnoricmnoric Member Posts: 4
    also, totally unrelated, but what exactly is the point of the ranks you get when you do things like get points for doing a tutorial quiz?
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited November 2012

    ...With that logic and with clockwise and turning both set to false at run time, the actor starts out not rotating. When you touch it, it goes back and forth between stopped and rotating clockwise. It never rotates counter-clockwise.
    Not sure why you were getting that; I tested out my suggestion and it worked fine, i.e start, clock, counter-clock, clock, counter-clock, etc.


    But OK, you want start, clock, counter-clock, stop, clock, counter-clock, stop, etc... so the Rules are different from the first version I gave, as I mentioned earlier.

    Because you have 3 options now, it's best to have the states all in one attribute.

    So make an integer attribute called Turning. You can do the following using the modulus (%) but the other way shown here is clearer as to what's going on:

    Rule: When touch is pressed
    Rule (nested in above) When self.Turning < 2
    Change Attribute self.Turning to self.Turning+1
    Otherwise
    Change Attribute self.Turning to 0


    Rule: When self.Turning = 1
    Rotate Clockwise Speed 90

    Rule: When self.Turning = 2
    Rotate Counter-Clockwise Speed 90

    Hope that sorts it for you now.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

Sign In or Register to comment.