Stop repeatedly_execute

Started by sloppy, Wed 22/02/2006 16:29:42

Previous topic - Next topic

sloppy

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.

DoorKnobHandle

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:

Code: ags

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.

sloppy

Okay, here's what I'm trying:
Code: ags

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?

DoorKnobHandle

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.

sloppy

If I remove one I get a "missing '}' "

Ashen

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.
I know what you're thinking ... Don't think that.

sloppy

I already posted the entire code above....
I haven't changed anything.

DoorKnobHandle

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!

sloppy

#8
Okay.Ã,  This is from the Global Script:
Code: ags

#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.

Ashen

Take away one of the three as dkh said, and add one at the very end (after the if ( skip_rep_ex == 1) condition).
I know what you're thinking ... Don't think that.

sloppy

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.

Ashen

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.)
I know what you're thinking ... Don't think that.

sloppy

I can't believe I missed that.  Thank you.

SMF spam blocked by CleanTalk