Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Squinky on Fri 26/12/2003 07:40:29

Title: Problem with Script
Post by: Squinky on Fri 26/12/2003 07:40:29

Okay, so I've got a character that moves around to different areas when you interact with him, and I keep tabs on him with globalint 2 and time it with timer 2...

it works the first time the roomes rep ex is run (when Gint ==1) but then when it comes time for the char to pop up again (when Gint ==3) it dosen't work. Now, I've tested the valuse of the int to make sure thats right and it is, but when I test the timer I get funny results. It seems like the timer never runs out the second time...anybody see what I'm doing wrong?


 // script for character6: Pick up character
if (GetGlobalInt (2)==0){
 
MoveCharacterBlocking (STAN,175,100,0);
Wait (10);
Display ("Animate bending down");
SetCharacterSpeed (SHELL,10);
MoveCharacterBlocking (SHELL,237, 90,0);
Wait (10);
PlaySound (2);
character[SHELL].room=-1;
SetTimer(2,150);
SetGlobalInt (2,1);

}
 
if (GetGlobalInt (2)==2){
 MoveCharacterBlocking (STAN,116, 97,0);
Wait (10);
Display ("Animate bending down");
PlaySound (2);
character[SHELL].room=-1;
SetTimer(2,150);
SetGlobalInt (2,3);
}


// the room rep ex

if ((IsTimerExpired (2)==1)&&(GetGlobalInt (2)==1)){
 character [SHELL].x=108;
 character[SHELL].y=88;
 PlaySound (2);
 character [SHELL].room=4;
 SetGlobalInt (2,2);
 }
 
if ((IsTimerExpired (2)==1)&&(GetGlobalInt (2)==3)){
 character [SHELL].x=222;
 character[SHELL].y=101;
 PlaySound (2);
 character [SHELL].room=4;
 SetGlobalInt (2,4);
 }

Title: Re:Problem with Script
Post by: MrColossal on Fri 26/12/2003 08:01:35
am i missing it or is there no code for changing the global int to 2 or 3, i take it that's in the character interaction?
Title: Re:Problem with Script
Post by: Squinky on Fri 26/12/2003 08:11:57
Damn, I wish it was that easy (probably is though) but no, I've got the character code followed by the room code, and the setting of that int to 3 is in the bottomest portion of the character code....

Title: Re:Problem with Script
Post by: a-v-o on Fri 26/12/2003 09:10:40
QuoteNote that this function will only return 1 once - after that, the timer is placed into an OFF state where it will always return 0 until restarted.

Change rep exec:

if (IsTimerExpired (2)==1){
if (GetGlobalInt (2)==1){
character [SHELL].x=108;
character[SHELL].y=88;
PlaySound (2);
character [SHELL].room=4;
SetGlobalInt (2,2);
}

else if (GetGlobalInt (2)==3){
character [SHELL].x=222;
character[SHELL].y=101;
PlaySound (2);
character [SHELL].room=4;
SetGlobalInt (2,4);
}
}

IsTimerExpired can't be called twice.
Title: Re:Problem with Script
Post by: Squinky on Fri 26/12/2003 18:03:03
That did it, thank you. I probably never would have figured that out...