Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: nightmarer on Mon 04/01/2021 23:57:03

Title: Showing the timer
Post by: nightmarer on Mon 04/01/2021 23:57:03
Hello!

In the game I am developing the main Character has x time to do one action before the time finishes and he needs to start again.
So far I have configured one timer running in checked by Repetely executed in Global Script which already knows when this Timer is over,
but I would like to stablish a count down in the game, so the player is able to see how much time left does he have,
but I didn't find any function to check the time left for the timer.
Can you please provide me any idea?

Regards.
Title: Re: Showing the timer
Post by: morganw on Tue 05/01/2021 01:23:08
I don't think there is any built-in function that allows you to read a timer value, but you can effectively create your own timer by making an integer variable to count down the frames as they elapse and use the value from GetGameSpeed to convert the counter value into another format.

i.e. if your game speed is 40 this means that repeatedly executing commands will be run 40 times per second, so a 2 second delay could mean decrementing the value from 80 to 0.
Title: Re: Showing the timer
Post by: nightmarer on Tue 05/01/2021 09:47:20
Hi.

Thanks for you answer. That is a solution.
Is there iny way to access to the class created in orger to build a get method?

Regards,
Title: Re: Showing the timer
Post by: Crimson Wizard on Tue 05/01/2021 09:52:57
I once wrote a timer module that allows to read remaining time, and some more: https://www.adventuregamestudio.co.uk/forums/index.php?topic=55545.0

Quote from: nightmarer on Tue 05/01/2021 09:47:20
Is there iny way to access to the class created in orger to build a get method?

Please clarify, what class are you refering to?
Title: Re: Showing the timer
Post by: nightmarer on Tue 05/01/2021 22:13:40
Thank you very much for your work.