Jump to content

How to add seconds to a timer


Chaman Calle

Recommended Posts

I have a countdown and a list of tasks that had to be performed while the time ticks away. However, every time you complete a task, there's some bonus time. I have tried the function "increment/decrement... Crono.Remaining + 15". However, it does not work properly.

 

How can I solve this? Is there any luacode that works fine?

 

Thank you!

post-5964721-029711500 1462469229_thumb.png

Link to comment

Off the top of my head, you might be able to do it this way:

-- Store the total number of seconds a user has in a variable. Any bonus time would be added to this.

-- Create another variable to store the number of seconds elapsed.

-- Use a one second timer. Every second, increment the number of seconds elapsed and check that against the total number of seconds variable.

-- If the user still has time, start the timer again.

 

Note the way described above might give the user an extra second of time due to the additional processing time accrued over the long run while checking the variables and starting the timer.

 

I could think more on this later, but that's a quick idea I had.

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...