NPC walking not working

Started by beomoud, Thu 03/04/2008 12:31:35

Previous topic - Next topic

beomoud

I'm sorry to bother you with this. What i wanted to do was have a character walk repeatedly from one place in a room to another. Right now he just  stands there, what have i done wrong in my code? Does anyone know? Here it is:

function room_Load()
{SetTimer(1, 800);
}

function room_RepExec()
{if (IsTimerExpired(1)){
  if (cBarman.Moving == false){
    mov1 ++;
    if (mov1 == 3) mov1 = 0;
   
    if (mov1 == 0){
    cBarman.Walk(420, 135);}
    else if (mov1 == 1){
    cBarman.Walk(1175, 210);}
    else if (mov1 == 2){
    cBarman.Walk(685, 250);}
  }
}
SetTimer(1, 800);
}

OneDollar

Your second SetTimer(1, 800); is outside the if (IsTimerExpired(1)){ loop, so on every game cycle the timer is reset to 800, and so never expires.

SSH

Also, make sure he's on a walkable area
12

beomoud

You where right about putting the SetTimer in the if  statement, i'm so embarrassed.

The other thing is that i already have another Timer(1) with a different time than this but that is at my global script, it didn't occur to me that it could jam it, at least not without giving me an error message. Well... case solved i guess. Again sorry to waste your time, you may completely delete this post if you like

SMF spam blocked by CleanTalk