Is there a way we can add a draining timer?

Learn how to use AAO by reading tutorials, and seek help from the AAO community.

Moderator: EN - Forum Moderators

Post Reply
Mosy
Posts: 76
Joined: Thu Aug 02, 2018 12:01 am
Gender: Male
Spoken languages: English

Is there a way we can add a draining timer?

Post by Mosy »

As the title says. I just wanna know if there's a way if we can run out of time by dawdling, resulting in a game over sequence, either by the life bar draining or by variables.
thank you!! :phoenix:
Live life as you enjoy it, pal!- :objection:
I guess not...
Image
User avatar
TimeAxis
Posts: 389
Joined: Fri Jan 01, 2021 8:27 pm
Spoken languages: English
Contact:

Re: Is there a way we can add a draining timer?

Post by TimeAxis »

Not in real time (it might be possible with clever use of the get_date function, but that's some advanced stuff, and I don't know of any instance of anyone successfully doing that), but you can do it per frame advancement. After each frame you want the timer to drain, just have a variable that decreases in value. Then have another frame that checks if the variable has hit 0 or whatever you want the "run out of time" amount to be, and redirects you to the game over frame once it's hit.

To do this, what you'd do is set an action at the beginning of the timed sequence where you define a variable (let's call it timer) to something like 100 or however long you want the timer to be.

Then to decrease that variable, you'd define it again, enter the same variable name, turn on advanced mode (the checkbox in the corner), and under the "variable value" section, click the "Load from runtime expression" checkbox. Then erase any quotation marks from the field and make sure it just reads

Code: Select all

timer - 1
, but replace "timer" with whatever you called the timer variable and 1 with however much you want it to decrease by.
Then you'd make a blank 1/100 second frame after that where you "evaluate conditions to redirect player" and if the variable is below however much you want it to be below, (something like this:

Code: Select all

timer < 1
) then go to whatever frame you want to go to when time runs out.

Actually displaying an in-game timer to go along with this would be a bit more complicated. You could probably do it by hiding and revealing various foreground objects, but it would be messy.

If you wanted to avoid the variables, you could also just drain life directly. That would have the benefit of also showing the life bar on screen as a representation of how much time is left, but then your timer and life bar wouldn't be independent.
Image
Question Arcs (Threads Coming Eventually)
ImageImageImageImage
Gaiden Episodes
Champion of Turnabouts ★
HALLOWEEN HERO
Other
Phoenix Wright: Ace Attornauts
The Curious Case of the Phantom Limousine (Coming Eventually)
The Imposter's Turnabout (Coming Maybe)
Mosy
Posts: 76
Joined: Thu Aug 02, 2018 12:01 am
Gender: Male
Spoken languages: English

Re: Is there a way we can add a draining timer?

Post by Mosy »

TimeAxis wrote: Fri May 28, 2021 5:27 am Not in real time (it might be possible with clever use of the get_date function, but that's some advanced stuff, and I don't know of any instance of anyone successfully doing that), but you can do it per frame advancement. After each frame you want the timer to drain, just have a variable that decreases in value. Then have another frame that checks if the variable has hit 0 or whatever you want the "run out of time" amount to be, and redirects you to the game over frame once it's hit.

To do this, what you'd do is set an action at the beginning of the timed sequence where you define a variable (let's call it timer) to something like 100 or however long you want the timer to be.

Then to decrease that variable, you'd define it again, enter the same variable name, turn on advanced mode (the checkbox in the corner), and under the "variable value" section, click the "Load from runtime expression" checkbox. Then erase any quotation marks from the field and make sure it just reads

Code: Select all

timer - 1
, but replace "timer" with whatever you called the timer variable and 1 with however much you want it to decrease by.
Then you'd make a blank 1/100 second frame after that where you "evaluate conditions to redirect player" and if the variable is below however much you want it to be below, (something like this:

Code: Select all

timer < 1
) then go to whatever frame you want to go to when time runs out.

Actually displaying an in-game timer to go along with this would be a bit more complicated. You could probably do it by hiding and revealing various foreground objects, but it would be messy.

If you wanted to avoid the variables, you could also just drain life directly. That would have the benefit of also showing the life bar on screen as a representation of how much time is left, but then your timer and life bar wouldn't be independent.
GENIUS IDEA! thank you very much! I just never knew variables could do such a thing because I always refrained from touching the advanced mode xD. If it doesn't work for me, I can just always use the life bar as you said.
this will work greatly, thanks again for the info :3
Live life as you enjoy it, pal!- :objection:
I guess not...
Image
User avatar
Enthalpy
Community Manager
Posts: 5169
Joined: Wed Jan 04, 2012 4:40 am
Gender: Male
Spoken languages: English, limited Spanish

Re: Is there a way we can add a draining timer?

Post by Enthalpy »

Yeah, timer settings like this are a job for variables. Feel free to ask if you run into any problems.
[D]isordered speech is not so much injury to the lips that give it forth, as to the disproportion and incoherence of things in themselves, so negligently expressed. ~ Ben Jonson
Mosy
Posts: 76
Joined: Thu Aug 02, 2018 12:01 am
Gender: Male
Spoken languages: English

Re: Is there a way we can add a draining timer?

Post by Mosy »

Enthalpy wrote: Fri May 28, 2021 1:52 pm Yeah, timer settings like this are a job for variables. Feel free to ask if you run into any problems.
Thank you :)
Live life as you enjoy it, pal!- :objection:
I guess not...
Image
Post Reply