Text Keeps Looping

Started by Wizzard, Fri 10/06/2011 14:07:56

Previous topic - Next topic

Wizzard

 ???
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
::)
Life is an adventure, but unfortunately you don't get restore points!!

Matti

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.

Ryan Timothy B

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:
Code: ags

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.

Wizzard

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
Life is an adventure, but unfortunately you don't get restore points!!

Wizzard

All sorted thanks to you guys. Works like a dream!!! ;D
Life is an adventure, but unfortunately you don't get restore points!!

SMF spam blocked by CleanTalk