Problem with repeatedly execute/SetTimer/IsTimerExpired

Started by Hobo Joe, Wed 07/01/2009 05:40:36

Previous topic - Next topic

Hobo Joe

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?
Yay, I'm Hobo..... Joe...

Trent R

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
Code: ags
if (IsTimerExpired(3))
without the '== 1' because it's a bool type.



~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Hobo Joe

Yay, I'm Hobo..... Joe...

Pumaman

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.

Hobo Joe

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.)

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

Code: ags
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.
Yay, I'm Hobo..... Joe...

Pumaman

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?

Hobo Joe

There is a line in the Line_Display script that says

if (!IsTimerExpired(TIMER))

Would that do it?

EDIT: Yep. I'm an idiot.
Yay, I'm Hobo..... Joe...

Khris

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.

SMF spam blocked by CleanTalk