Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Wizzard on Fri 10/06/2011 14:07:56

Title: Text Keeps Looping
Post by: Wizzard on Fri 10/06/2011 14:07:56
 ???
I think it's probably something I'm not doing properly, but when I set text to show above player character it doesn't time out, it keeps looping.

I'm using the script command cEgo.Say("My message text....."); 
This command follows a standing on hotspot script line.
I've tried setting text speed with: game.text_speed = 10 or some other value but this only changes the speed of the repeating text.

Can someone please tell me where I'm going wrong as it is most unlikely that AGS is at fault.
Thanks in advance
::)
Title: Re: Text Keeps Looping
Post by: Matti on Fri 10/06/2011 14:20:39
If the character is constantly standing on the hotspot then consequently the .Say command is constantly being repeated..

Either use a region and the "walks onto" function or use a variable to stop the command from being called again.
Title: Re: Text Keeps Looping
Post by: Ryan Timothy B on Fri 10/06/2011 14:27:27
AGS will check if you're standing on the hotspot. It will run the hotspot_walkOn() function. It will run the line of code with the say command.
It will then recycle through the script. It'll check if you're on the hotspot. It will run the hotspot_walkOn() function again. Run the code again with the say command.

One way around this would be to use the Game.DoOnceOnly function:

function hHotspot_WalkOn()
{
  if (Game.DoOnceOnly("stands on hotspot"))
  {
    cEgo.Say("My message text....."); 
    //etc...
  }
}


It will still run the function every time you walk on that hotspot, it just won't run the lines of script within the DoOnceOnly.
Title: Re: Text Keeps Looping
Post by: Wizzard on Fri 10/06/2011 14:29:57
Thanks for the quick reply on that one matti. It was beginning to drive me nuts. Yes I see what you mean, and it should have been obvious.
Also thankyou Ryan, I will also try that method.
Regards Mike
Title: Re: Text Keeps Looping
Post by: Wizzard on Fri 10/06/2011 16:27:42
All sorted thanks to you guys. Works like a dream!!! ;D