Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: miguel on Fri 06/06/2003 17:16:59

Title: timer problems
Post by: miguel on Fri 06/06/2003 17:16:59
hello to all,
I have a bit of a problem here, this script is part of a puzzle I am trying to make, basically I need that a npc moves out of EGO's way by triggering something in the room,
//
int temp=0;
function scratch() {
 temp++;
 if (temp>=240) temp=0;
 if (temp==120) LoseInventory(8);
 if (temp==10) DisplaySpeechBackground(BUGONE,"SCRATCH");
 if (temp==50) DisplaySpeechBackground(BUGTWO,"SCRATCH");
 if (temp==100) DisplaySpeechBackground(BUGTHREE,"SCRATCH");
 if (temp==110) MoveCharacterBlocking(COOK,118,57,1);DisplaySpeechBackground(COOK,"Hey, who's there? That door is locked, you stinky mule!");
 if (temp==230) MoveCharacterBlocking(COOK,118,87,1);DisplaySpeechBackground(COOK,"What a jerk!");
 }

The editor gives me an error when I try to perform this function saying that there are to many screen overlays,
I understand that I am using to many DisplayScreenBackground comands, so how do I trigger a different function outside (repeatedly_execute) because I've tryed and it simply doesnt work,
I hope I explained it well
thanks
Title: Re:timer problems
Post by: Scorpiorus on Sat 07/06/2003 00:31:14
Have you the scratch() function inside the repeatedly execute?

The error may occur if you run DisplaySpeechBackground() repeatedly without removing the previous text overlays it has created.

If it's inside repeatedly then try to increase intervals:

if (temp>=500) temp=0;

Also I guess you need some braces to be placed:

....
....
if (temp==110) {
MoveCharacterBlockingCOOK,118,57,1);
DisplaySpeechBackground(COOK,"Hey, who's there? That door is locked, you stinky mule!");
}
if (temp==230) {
MoveCharacterBlocking(COOK,118,87,1);
DisplaySpeechBackground(COOK,"What a jerk!");
}
} //enf of function

let me know how it works

EDIT: yep, the problem in braces. Without them you have DisplaySpeechBackground() calling on each game loop. ;)

-Cheers
Title: Re:timer problems
Post by: miguel on Sat 07/06/2003 01:44:44
thanks scorpiorus, it was the "{" missing,
sorry for the trouble and happy coding