Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: sloppy on Wed 22/02/2006 16:29:42

Title: Stop repeatedly_execute
Post by: sloppy on Wed 22/02/2006 16:29:42
Right now I have an NPC doing something in the background with a blank view above him providing random text sound effects. (rattle, tap tap, etc.) This I put as SayBackground in the Repeat_Execute in the interaction editor.

When I talk to the NPC, I want the text sounds to stop and then resume when the conversation ends and the NPC goes back to what he's doing.  How would I temporarily stop what's in the Repeatedly_Execute?

Hope this makes sense.
Title: Re: Stop repeatedly_execute
Post by: DoorKnobHandle on Wed 22/02/2006 16:35:36
Well, you could use a variable after all. Just call it "int skip_rep_ex" and set it to 1 if you want to skip the rep_ex function and to 0 if you want to run it. Then add this to your actual rep_ex function:


if ( skip_rep_ex == 0 )
// only if we don't want to skip the rep_ex function
{
   // do your stuff now...
}


That's atleast one way that would work.
Title: Re: Stop repeatedly_execute
Post by: sloppy on Wed 22/02/2006 17:14:37
Okay, here's what I'm trying:

if ( skip_rep_ex == 0 ) {
if (pause > 0 ) {
pause--;
}
else if (speakline==Random(3)) {
Ã,  character[BLA].SayBackground("Sentence 1!");
Ã,  pause = 3*GetGameSpeed();
Ã,  speakline=2;
Ã,  }
else if (speakline==Random(3)) {
Ã,  character[BLA].SayBackground("Sentence 2!!");
Ã,  pause = 3*GetGameSpeed();
Ã,  speakline=3;
}
else if (speakline==Random(3)) {
Ã,  character[BLA].SayBackground("Sentence 3!!!");
Ã,  pause = 3*GetGameSpeed();
Ã,  speakline=1;
}
}Ã, 
}

if ( skip_rep_ex == 1 ) {
Ã,  character[BLA].Say(" ");
}


But I get an error that there's an unexpected "if" at the bottom of the code.Ã,  Shouldn't this work?
Title: Re: Stop repeatedly_execute
Post by: DoorKnobHandle on Wed 22/02/2006 17:17:35
You have 1 closing bracket too much (or many?). Get rid of one of those three that are written after each other, that should help if I'm not completly blind.
Title: Re: Stop repeatedly_execute
Post by: sloppy on Wed 22/02/2006 17:28:23
If I remove one I get a "missing '}' "
Title: Re: Stop repeatedly_execute
Post by: Ashen on Wed 22/02/2006 17:30:38
I would've posted the same thing before, but dkh beat me to it...

Can you post the whole repeatedly_execute script? It looks like the problem is just matching them up properly.
Title: Re: Stop repeatedly_execute
Post by: sloppy on Wed 22/02/2006 17:44:58
I already posted the entire code above....
I haven't changed anything.
Title: Re: Stop repeatedly_execute
Post by: DoorKnobHandle on Wed 22/02/2006 17:49:34
Then you'll need to add one more to the bottom (inbetween the closing bracket for the rep_ex function and the last one that you posted here).

But that will only work if the rep_ex really ONLY consists of what you posted here! So, I take it that it says "function rep_ex ( ) {" right ABOVE what you just posted and that there is one closing "}" right AFTER what you posted, right?

If it still doesn't work, then please post the code WITH the "function rep_ex ( )" line and all that comes until the next function opens!
Title: Re: Stop repeatedly_execute
Post by: sloppy on Wed 22/02/2006 18:06:48
Okay.Ã,  This is from the Global Script:

#sectionstart room_aÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function room_a() {
Ã,  // script for Room: Repeatedly execute
if ( skip_rep_ex == 0 ) {
if (pause > 0 )
pause--;
}
else if (speakline==Random(3)) {
Ã,  character[BLA].SayBackground("Sentence 1!");
Ã,  pause = 3*GetGameSpeed();
Ã,  speakline=2;
Ã,  }
else if (speakline==Random(3)) {
Ã,  character[BLA].SayBackground("Sentence 2!!");
Ã,  pause = 3*GetGameSpeed();
Ã,  speakline=3;
}
else if (speakline==Random(3)) {
Ã,  character[BLA].SayBackground("Sentence 3!!!");
Ã,  pause = 3*GetGameSpeed();
Ã,  speakline=1;
}
}Ã, 
}
if ( skip_rep_ex == 1 ) {
Ã,  character[BLA].Say("");
}


Hope this is what you meant.
Title: Re: Stop repeatedly_execute
Post by: Ashen on Wed 22/02/2006 18:23:03
Take away one of the three as dkh said, and add one at the very end (after the if ( skip_rep_ex == 1) condition).
Title: Re: Stop repeatedly_execute
Post by: sloppy on Wed 22/02/2006 19:16:54
Sorry, but I still get the "unexpected if" message and it points to the "if ( skip_rep_ex == 1 )."   I'm not sure what else it could be.
Title: Re: Stop repeatedly_execute
Post by: Ashen on Wed 22/02/2006 23:27:41
OK, I see it now - you're also missing an opening brace on the line if (pause > 0 ).

That should be it now, assuming the next line is the #sectionend bit. If it hasn't worked, use Ctrl-B to match all the braces and see where else the problem might be - it almost certainly IS a brace problem. (Another thing to try would be making if ( skip_rep_ex == 1 ) an else if.)
Title: Re: Stop repeatedly_execute
Post by: sloppy on Thu 23/02/2006 02:48:37
I can't believe I missed that.  Thank you.