Why can't I run NewRoom from repeatedly_execute_always? [SOLVED]

Started by Kinoko, Tue 22/03/2005 03:05:57

Previous topic - Next topic

Kinoko

I have a trigger in a room that sets off a function, and at the end of that function, a timer is set:

Code: ags

if (IsTimerExpired(5)) {
  if (cue==1) TypeLineInvis("The great and powerful woman who created the lands, the oceans, the skies...", 20, 160, 2, 10, 200);
  else if (cue==2) {
    NewRoom(31);
    cue=0;
}


What should happen, is that initially, cue=0, then the function is run from the room which results in cue=1 and the timer starting. So, after that's expired, a second function is run which changes cue to 2, and... what I'd like to happen, is for NewRoom to work here.

It doesn't, because it tells me that this function can't be run from repeatedly_execute_always. I understand the need for this, but I have the code set up that it will only be called once, so there's no danger of it repeating. I tried putting NewRoom(31) into a seperate function and running that from repeatedly_execute_always but that still counts as running NewRoom from there.

Can I get around this?

Vince Twelve

#1
I ran a quick test and don't seem to have any problem implementing this kind of maneuver.

It may just have been cut out by your copy/paste job, but you are missing a "}" in there...

If that doesn't fix it, there may be an issue with this in a version of AGS that I'm not using...

EDIT:  ACK!  I'm an idiot.  Didn't see the "always" part of repeatedly_execute_always...

That's right, I forgot you can't run a lot of functions from r_e_a.

If you NEED to run it from r_e_a then I'm no help at this point.

Kweepa

You ought to be able to run it from repeatedly_execute... (not _always because NewRoom is blocking).

Quote from: Manual
repeatedly_execute()
Called every game cycle (normally 40 times per second).
repeatedly_execute_always()
Called every game cycle, even when a blocking routine (eg. speech/cutscene) is in progress. You cannot call any blocking functions from this event handler. You can have a repeatedly_execute_always function in both your global script and in any room scripts where you require it.
Still waiting for Purity of the Surf II

Kinoko


SMF spam blocked by CleanTalk