Is it possible to write a timer?

Started by Mr_Frisby, Fri 23/05/2003 05:39:53

Previous topic - Next topic

Mr_Frisby

I had an idea for a puzzle and wondered if it was possible to allow a character to stand on a hot spot and still be able to interact within the game, but at the same time only be allowed on that hot spot for say ten or tweny seconds before being forced to move.
Say, if the hotspot was sharp or cold ect.
Is there a way of scripting : if character x on hotspot for (length of time)
move character to (x,y) ?
or something like that (or even on a walkable area)

This question may have been asked before but I couldn't seem to see it here.

If anyone knows the answer to this problem or could direct me to a tute - it would be very helpy.

thanks :)
Hey! All my awesome trophies dissapeared in the year since I was here last. CONSARN_IT! with an underscore!!! I earned dem tings!! Oh well. Hope your Monkey floats.

Gilbert

There're lots of way to write timed action. In fact, there're already timers defined internally to the engine, read about SetTimer() and IsTimerExpired() from

Text Script Functions -> Game/Global Functions

Section of the AGS manual.

You can also set up a counter which you can increment it every game loop, etc. (An example is in
Text Scripting Tutorial -> Tutorial Part 2
of the Manual)

Of course, you can also the clock functions, etc.

There're so many ways to do that, and I'm just too lazy busy to come out with an concrete example at the moment. ;D

Andail

For example, you could set timer #1 when the character first steps on the hotspot to around ten seconds like this:
SetTimer (1, 400);

under the repeatedly execute function you put:
If (IsTimerExpired (1) == 1){ // will check if the timer is expired, which would return 1.
  MoveCharacterBlocking (EGO, x, y, 1);  //to force him out
}
 

Scorpiorus

And if you use the latest AGS v2.55 RC1 you should use regions instead of hotspots since with the recent version appeared the last ones aren't supposed to be used for character stand-on interactions anymore. Moreover with the regions you can use some handy interactions:
Player walks onto region
occurs when the player moves from another region onto this one. Will also activate on whichever region they start on when they enter the screen.

So, as Andail suggested, place SetTimer (1, 400); inside the region interaction:

Player walks onto region:
SetTimer (1, 400);

then check for timer in repeatedly.

-Cheers

Mr_Frisby

Thanxs for that (I couldn't see that in the manual for looking).
Hey! All my awesome trophies dissapeared in the year since I was here last. CONSARN_IT! with an underscore!!! I earned dem tings!! Oh well. Hope your Monkey floats.

SMF spam blocked by CleanTalk