Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Hobo Joe on Wed 07/01/2009 05:40:36

Title: Problem with repeatedly execute/SetTimer/IsTimerExpired
Post by: Hobo Joe on Wed 07/01/2009 05:40:36
Here's my scripts (both in same room):

function hHotspot5_WalkOn()
{
cEgo.StopMoving ();
DisableInterface();
cEgo.SetWalkSpeed (8, 8);
cEgo.WalkStraight (cEgo.x, 170, eBlock);
StopAmbientSound(1);
PlayAmbientSound(1, 2, 255, 0, 0);
cEgo.ChangeView(2);
cEgo.Animate(0, 4, eRepeat, eNoBlock);
SetTimer(3, 80);

and

function room_RepExec()
{
if (IsTimerExpired(3) == 1){
  cEgo.Transparency = 100;
  object[0].Visible = false;
}
}

Problem is that the character and the object don't disappear. What gives?
Title: Re: Problem with repeatedly execute/SetTimer/IsTimerExpired
Post by: Trent R on Wed 07/01/2009 07:14:43
Is it possible that any of those are blocking commands (it's late and I don't feel like paying too much attention or checking them in the manual)? If so, maybe putting it under repeatedly_execute_always() would help.

Also, I do know that your second function can be shortened as if (IsTimerExpired(3)) without the '== 1' because it's a bool type.



~Trent
Title: Re: Problem with repeatedly execute/SetTimer/IsTimerExpired
Post by: Hobo Joe on Wed 07/01/2009 07:31:47
Where can I find/put repeatedly_execute_always?
Title: Re: Problem with repeatedly execute/SetTimer/IsTimerExpired
Post by: Pumaman on Wed 07/01/2009 18:29:13
Is there anything else in your WalkOn script after the SetTimer call?

Place a breakpoint on the "if (IsTimerExpired(3) == 1){" line (click on the line and press F9), and see if it is being processed.
Title: Re: Problem with repeatedly execute/SetTimer/IsTimerExpired
Post by: Hobo Joe on Wed 07/01/2009 20:54:37
Yeah, sorry. The whole script looks like this (except the ACTUAL string, as I don't want you to know what that says... I'm being secretive.)

function hHotspot7_WalkOn()
{
cEgo.StopMoving ();
DisableInterface();
cEgo.SetWalkSpeed (8, 8);
cEgo.Walk (189, 128, eBlock, eAnywhere);
StopAmbientSound(1);
PlayAmbientSound(1, 2, 255, 0, 0);
cEgo.StopMoving ();
cEgo.Transparency = 100;
cEgo.x = 200;
cEgo.y = 200;
SetWalkBehindBase(3, 200);
SetWalkBehindBase(1, 200);
object[0].Visible = true;
object[0].SetView(2);
object[0].Animate(0, 4, eRepeat, eNoBlock, eForwards);
SetTimer(1, 80);
DisplayLD("I'm hiding the text because I'm a jerk");
}


and

function room_RepExec()
{
bool found;
  int x,y;
  if (!cChar.Moving) {
    while(!found) {
      x = Random(Room.Width);
      y = Random(Room.Height);
      if (Region.GetAtRoomXY(x, y) == region[1]) found = true;
    }
    cChar.Walk(x, y);
  }
 
if (IsTimerExpired(1) == 1){
  object[0].Visible = false;
}
if (IsTimerExpired(2) ==1){
PlayAmbientSound (1, 1, 255, 0, 0);
}
}


The second timer (to start the ambient sound after loading) works fine. It's the first one that doesn't make the object disappear.

EDIT: Also, for reference, DisplayLD is calling a script module Khris made for me to make a specific kind of scrolling, non-blocking text.
Title: Re: Problem with repeatedly execute/SetTimer/IsTimerExpired
Post by: Pumaman on Wed 07/01/2009 21:04:18
The code looks fine on the face of it. I take it you're not using Timer 1 somewhere else in the game (eg. global script) as well, and that some script somewhere else might be processing it instead?
Title: Re: Problem with repeatedly execute/SetTimer/IsTimerExpired
Post by: Hobo Joe on Wed 07/01/2009 21:52:22
There is a line in the Line_Display script that says

if (!IsTimerExpired(TIMER))

Would that do it?

EDIT: Yep. I'm an idiot.
Title: Re: Problem with repeatedly execute/SetTimer/IsTimerExpired
Post by: Khris on Wed 07/01/2009 23:06:03
Right, sorry, I should have mentioned that. At the top of the module, the constant TIMER is declared. Just change the number to a timer that's not in use.