help with timers and repexec for a continuous background cutscene [SOLVED]

Started by Ardentsideburns, Mon 22/08/2016 01:09:52

Previous topic - Next topic

Ardentsideburns

so my intention here is to have to characters have a dialogue in the background while the character passes them by, i thought it would be something somewhat simple but boy was i wrong..
so here the code i wrote...

Code: ags
function room_Load()
{
Turquoise.Name=("Fancy lady"); 
Alberich.Name=("Nervous guy"); 


 if (loop==0){
  SetTimer(1, 10);
   }
 if (loop==1){
  SetTimer(2, 10);
   }
   
  if (loop==2){
  SetTimer(3, 10);
   }
}


function room_RepExec()
{
  if(IsTimerExpired(1)){
  Turquoise.LockView(66);
  Alberich.LockView(8);
  Turquoise.Animate(0, 4, eRepeat, eNoBlock );
  Alberich.Animate(0, 1, eRepeat, eNoBlock );
  Turquoise.SayBackground("psst psst psst");
  loop++;
  }
 if(IsTimerExpired(2)){
  Turquoise.LockView(18);
  Alberich.LockView(12);
  Alberich.Animate(0, 1, eRepeat, eNoBlock );
  Turquoise.Animate(0, 4, eRepeat, eNoBlock );
  Alberich.SayBackground("whisper whisper whisper");
  loop++;
  }
if(IsTimerExpired(3)){
        Turquoise.LockView(66);
        Alberich.LockView(8);
        Alberich.Animate(0, 1, eRepeat, eNoBlock );
        Turquoise.Animate(0, 4, eRepeat, eNoBlock );
        Turquoise.SayBackground("mumble mumble mumble");
        loop--;
        loop--;
        }

}


ugh, what am i not getting? the code advances only when i exit and the re enter the room, so it is recognizing the timer and the loop variable, but i don't understand why it doesn't continuously check if the timers have expired... to make it clear, the characters execute the first part of the script (the psst psst psst part) then stop ,locked in the animation i set for them .When i exit and reenter the room they move forward with the second part of the script (the whisper whisper whisper part) and so on and so forth looping back to the first part when the loop variable gets reset to 0. What i want is that this whole script is executed continuosly in the background at regular intervals set by the timers... anyone can help me , please? i'm really stumped...

Mandle

I think it's because you are only starting the timers when the room is entered.

Try starting the next timer at the end of each "if" check, right after Loop++;

You may also need something like:

Code: ags

if(IsTimerExpired(1) && Loop==0){


(and so on for the other two checks)

Matti

As Mandle said, you've put the check in the room script, so it's only called once after entering the room.

Quote from: Mandle on Mon 22/08/2016 05:03:26
Try starting the next timer at the end of each "if" check, right after Loop++;

If the only use of the "Loop" variable is to check what timer should be set next, then you don't need it. You could just replace the loop++/loop-- with the next SetTimer:

Code: ags
function room_Load()
{
  Turquoise.Name=("Fancy lady"); 
  Alberich.Name=("Nervous guy"); 
}


function room_RepExec()
{
  if(IsTimerExpired(1)){
    Turquoise.LockView(66);
    Alberich.LockView(8);
    Turquoise.Animate(0, 4, eRepeat, eNoBlock );
    Alberich.Animate(0, 1, eRepeat, eNoBlock );
    Turquoise.SayBackground("psst psst psst");
    SetTimer(2, 10);
  }
  if(IsTimerExpired(2)){
    Turquoise.LockView(18);
    Alberich.LockView(12);
    Alberich.Animate(0, 1, eRepeat, eNoBlock );
    Turquoise.Animate(0, 4, eRepeat, eNoBlock );
    Alberich.SayBackground("whisper whisper whisper");
    SetTimer(3, 10);
  }
  if(IsTimerExpired(3)){
    Turquoise.LockView(66);
    Alberich.LockView(8);
    Alberich.Animate(0, 1, eRepeat, eNoBlock );
    Turquoise.Animate(0, 4, eRepeat, eNoBlock );
    Turquoise.SayBackground("mumble mumble mumble");
    SetTimer(1, 10);
  }
}

Ardentsideburns

i tried, but nothing seems to happen. it seems that repexec isn't really capable of starting a timer for some reason..?

Ardentsideburns

Anyways, i dug a bit in the forums and found a post containing a solution; this post has exactly what i needed for this to work :
http://www.adventuregamestudio.co.uk/forums/index.php?topic=12434.msg157183#msg157183

Matti

Quote from: Ardentsideburns on Mon 22/08/2016 14:20:23
i tried, but nothing seems to happen. it seems that repexec isn't really capable of starting a timer for some reason..?

Ah, sorry, I forgot to note that you'd have to set a timer once before the rep exe is called (on room_load or game_start for example).

SMF spam blocked by CleanTalk