Timer question
Tomsa
11 Apr 2009, 18:07When I enter a room, an object will be available for interaction, let us call that object "man".
Above event will trigger a timer that will say different things every 10 seconds.
Example:
"You see a suspicious looking man in the distance...10 s...the man is approaching you...10 s...the man approaching you looks hostile...10 s...you feel the adrenaline rush to your head as you see the iron bar in his hands."
When the final message is displayed, something happens (procedure or whatever), ending the timer.
How do I do this?
Above event will trigger a timer that will say different things every 10 seconds.
Example:
"You see a suspicious looking man in the distance...10 s...the man is approaching you...10 s...the man approaching you looks hostile...10 s...you feel the adrenaline rush to your head as you see the iron bar in his hands."
When the final message is displayed, something happens (procedure or whatever), ending the timer.
How do I do this?
Redsun
12 Apr 2009, 06:37I'd use two timers to do this, the 2nd timer would only be used
to start the 1st timer and end the 2nd timer.
I'd use a var that increts 1 every time the 1st timer is ran.
Then I'd have the 1st timer set to 10 seconds, and also
within the 1st timer you'd run some if statements.
TIMER 1
if var(the one that gets increped) is equal to 1
then "you see a man in the distance..."
turn off this timer and turn on timer 2
TIMER 2
Only thing in timer two is
Turn off timer two and turn on timer one.
TIMER 1
if var is equal to 2
then "the man is approaching you..."
turn off this timer and turn on timer 2
etc
Keep adding to this as much as you like.
at the end, when the var has reached the end count, simply
run a proc and end the timer.
to start the 1st timer and end the 2nd timer.
I'd use a var that increts 1 every time the 1st timer is ran.
Then I'd have the 1st timer set to 10 seconds, and also
within the 1st timer you'd run some if statements.
TIMER 1
if var(the one that gets increped) is equal to 1
then "you see a man in the distance..."
turn off this timer and turn on timer 2
TIMER 2
Only thing in timer two is
Turn off timer two and turn on timer one.
TIMER 1
if var is equal to 2
then "the man is approaching you..."
turn off this timer and turn on timer 2
etc
Keep adding to this as much as you like.
at the end, when the var has reached the end count, simply
run a proc and end the timer.
Redsun
12 Apr 2009, 19:25also keep in mind you must first turn on timer two before you turn off timer one
and in timer two you must first turn on timer one then turn off timer two.
and in timer two you must first turn on timer one then turn off timer two.
paul_one
12 Apr 2009, 19:40Simple game to illustrate 1 timer, 1 variable, and some small commands.
In my game, you can attack the man - which stops the timer working (because he's dead - obviously) or you can leave the room (in which case, you're safe and out of the room).
Once you get back into the room however, he continues (and I didn't reset the counter because I was a bit lazy and thought he'd be about the same distance still).
I shortened the time to 5 seconds (which can be changed easily) because it's easier to demonstrate with a short time.
You get 5 timer events before he kills you (again, can be changed easily in the timer) - which ends up being about 25 seconds.
It's customizable in the fact you can have MANY people, and each give them special "attack" actions so they do different things when they're attacked (try attacking the cactus!).
So, there ya go, see how that is for you.
In my game, you can attack the man - which stops the timer working (because he's dead - obviously) or you can leave the room (in which case, you're safe and out of the room).
Once you get back into the room however, he continues (and I didn't reset the counter because I was a bit lazy and thought he'd be about the same distance still).
I shortened the time to 5 seconds (which can be changed easily) because it's easier to demonstrate with a short time.
You get 5 timer events before he kills you (again, can be changed easily in the timer) - which ends up being about 25 seconds.
It's customizable in the fact you can have MANY people, and each give them special "attack" actions so they do different things when they're attacked (try attacking the cactus!).
So, there ya go, see how that is for you.