Jump to content

Timer - Getting time remaining


Ranger Fox

Recommended Posts

I want to display how much time is remaining on a timer.

 

Let's say the timer's name is "Timer", such that the Lua code's object name is "ztimerTimer".

 

I looked at the following web site: http://www.evilmana.com/tutorials/lua_tutorial_11.php

 

I have tried the following and everything failed:

ztimerTimer:time()

ztimerTimer.time

ztimerTimer.time()

ztimerTimer:Time()

ztimerTimer:Time

 

Is Groundspeak encapsulating the timer?

 

For those interested, I'm giving the user a stopwatch item that will show the time remaining. I have a second timer firing at an interval of five seconds. On each tick, the following code will be executed such that the stopwatch item's description will display the timer's seconds remaining:

zitemStopwatch.Description = ztimerTimer:time() .. " seconds left"

Link to comment

I want to display how much time is remaining on a timer.

 

Let's say the timer's name is "Timer", such that the Lua code's object name is "ztimerTimer".

 

I looked at the following web site: http://www.evilmana.com/tutorials/lua_tutorial_11.php

 

I have tried the following and everything failed:

ztimerTimer:time()

ztimerTimer.time

ztimerTimer.time()

ztimerTimer:Time()

ztimerTimer:Time

 

Is Groundspeak encapsulating the timer?

 

For those interested, I'm giving the user a stopwatch item that will show the time remaining. I have a second timer firing at an interval of five seconds. On each tick, the following code will be executed such that the stopwatch item's description will display the timer's seconds remaining:

zitemStopwatch.Description = ztimerTimer:time() .. " seconds left"

Yes for the timer, we are encapsulating it. Part of the reason is to track the timer if the user turns off the device and the other part is because we don't have the luxury on the Garmin device to access system stuff. You could keep your own variable and track the time that way. We could in the future, provide those kinds of attributes for it though.

 

David.

Edited by davidloew
Link to comment

Yes, I think a feature like that might be sensible to include in a future release. Many games utilizing countdown timers as part of its story could certainly use the feature of displaying remaining time to a player.

I was thinking about this and you could use the os.date and os.time features or simply a numeric seconds variable. Then, when the timer tick occurs, decrement the seconds variable. And, with the SetStatusText that is implemented on the ppc, you could display the seconds countdown.

 

Looking at the link you sent, I believe that is a PSP implemented timer just like our Wherigo Timer. The lua system has no timer built in. I may create a sample so see what it looks like.

 

David

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...