Stopping a rule?

iammichaeldavisiammichaeldavis Member Posts: 4
edited November -1 in Working with GS (Mac)
I've tried searching on Google and in this forum, and I can't find any mention of this, even though I'm sure I'll get a response that's a link to someone else already covering this and I'll look like I didn't even try searching before asking, but:

Is there any way to stop a rule? I have a situation where I have an actor waiting on an event. When the event occurs (a global variable becoming 'true') then I want the actor to perform a task ONLY if a second global variable is also true. If it isn't, do nothing.

So I have:

Rule 1-1: if x=true, then:
Rule 1-2: if y=true, then A.
if y=false, then B.

I only want rule 1-2 to run one time, not infinitely, which is what happens now.

Is there any way I can make a rule run only one time?

Comments

  • POMPOM Member Posts: 2,599
    Yes ,
    Create self.attribute - boolean - call it "one time only" (or whatever name you want) and set it to false.

    wrap your " Rule 1-2: if y=true, then A " in a rule say that :

    When "one time only" is FALSE
    When Rule 1-2: if y=true
    do bla bla bla and change "one time only" to true .

    Hope it helps .
    Roy.
  • iammichaeldavisiammichaeldavis Member Posts: 4
    That's actually really helpful, and I tried to implement that... Maybe instead of using hypotheticals, I should describe my situation a little better.

    To learn how to use GameSalad, I wanted to re-create one of those old Tiger handhelds, like this one: http://www.8-track-shack.com/1988-tiger-miniature-golf-handheld-video-game-p-35839.html.

    So I have three actors in a row in the scene: dude1, dude2, dude3, they all have alphas set to zero. I have a fourth actor called Trigger. When Trigger gets touched, he changed the global attribute "dude1_go" to "true".

    Dude1 has a rule that says:

    1. When Attribute "dude1_go" is True:
    1-1. Change Attribute "dude1_go" to False.
    1-2. Make my own Alpha "1" (display the dude)
    1-3. Timer - wait a second, then:
    1-3-1. Make my own Alpha "0" (hide the dude again)
    1-3-2. Make attribute "dude2_go" True. (activate the next dude, who has the same set of rules.

    So I've got 20 of these guys in a chain now, and it all works fine. I trigger the first guy, and they all fire off one by one.

    Now, the trouble starts when I wanted to make a guy in the middle of the chain have a forking decision. I want him to keep the chain going if a global attribute called "pad-active" is set to true, if it's false, I want the chain to stop. When dude5 sets "dude6_on" and dude6 turns himself on, it starts off similar to the rest of the guys:

    1. When Attribute "dude6_go" is True:
    1-1. Change Attribute "dude6_go" to False.
    1-2. Make my own Alpha "1" (display the dude)
    1-3. Timer - wait a half second, then:
    1-3-1. New rule: is "pad-active" set true? Then:
    1-3-1-1. Make my own Alpha "0" (hide the dude again)
    1-3-1-2. Make attribute "dude7_go" True. (activate the next dude)
    1-3-2. Was pad-active false? then:
    1-3-2-1. Make my own Alpha "0" (hide the guy no matter what"
    1-3-2-2. Lower the lives counter.

    So this all makes sense to me, and I'm used to Javascript scripting so I assumed all these rules would be one offs. But once the "is the pad active" rule comes into play, it never ends. I can set pad-active on and off as many times as I want and the criteria for those rules will
    keep going, the life counter just lowers and lowers.

    So I took you advice, and added another variable, where right before the "is pad active rule" happens, a boolean gets turned true, and no matter whether the pad is active or not, both outcomes turn that boolean false. It didn't change anything, the rule still runs forever.
  • iammichaeldavisiammichaeldavis Member Posts: 4
    Also, I can make this work a lot simpler by just spawning the dude who makes the "decision", having him perform A or B, then destroying himself, and I get my "run once" rule. But from the forums, it appears that destroying an actor doesn't release the memory he was using, and this game is intended to run in perpetuity, until you lose all your lives. So I'm assuming eventually memory leaks will crash the app. But those threads are all around a year old, so, has this problem been fixed? If you destroy an actor, is he still a terminate-and-stay-resident leak, or does he truly despawn and leave the device's RAM?
Sign In or Register to comment.