Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document GetTimerPos in Globalfunctions_General #269

Closed
ericoporto opened this issue Nov 21, 2024 · 3 comments
Closed

Document GetTimerPos in Globalfunctions_General #269

ericoporto opened this issue Nov 21, 2024 · 3 comments

Comments

@ericoporto
Copy link
Member

ericoporto commented Nov 21, 2024

https://github.com/adventuregamestudio/ags-manual/wiki/Globalfunctions_General#settimer

int  GetTimerPos(int timerID)

This function returns the remaining ticks for the timer timerID. It will return 0 when the timer is not running and 1 when it's expiring.

There are 20 available timers, with timerIDs from 1 to 20. This function will error if the timerID is invalid, either lower than 1 or bigger than 20.

problem: can't figure a good example for this, perhaps a bomb with a counter in a label?

/// Returns the specified timer's time value; returns 0 if timer is not running, and 1 if it's expiring.
import int  GetTimerPos(int timerID);

What I'm suggesting here is a GetTimer() function, which simply returns the number of cycles left on a timer. My reason for this is twofold. Firstly, sometimes you'll want to be able to do something in the middle of a timer, without setting up another timer. Secondly, it would provide a way to see whether or not a timer is running, without incurring the IsTimerExpired()'s OFF state.

Needs a See also to SetTimer.

@ericoporto ericoporto added this to the AGS 3.6.2 milestone Nov 21, 2024
@ericoporto ericoporto mentioned this issue Nov 21, 2024
43 tasks
@ericoporto
Copy link
Member Author

Documented below but the example isn't actually working, maybe a bug in the engine. I will leave it open until more information is available.

https://github.com/adventuregamestudio/ags-manual/wiki/_compare/acbcd18831b23ccee965ae00580ec25e57a71a2f...7186d4cfcdfdc2384cd9e81451a893c6d387b76a

@ericoporto
Copy link
Member Author

Fixed docs https://github.com/adventuregamestudio/ags-manual/wiki/_compare/7186d4cfcdfdc2384cd9e81451a893c6d387b76a...4cfe75c98c819f23e704883fb6cdff54fd372dc8

From comment in forums

https://www.adventuregamestudio.co.uk/forums/editor-development/feature-request-gettimer-function/msg636667761/#msg636667761

@eri0o this is the problem with the current Timer implementation. It stays at 1 UNTIL user calls IsTimerExpired.
Add IsTimerExpired check somewhere in the script, and that should fix this infinite timer.

@ericoporto
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant