Copied from ProjectSpark.com

How do I create a Game timer?

Question: How do I show how much time the game has been running as a clock?

The answer given used countdown timers and didn’t use the inbuilt gametime tile. So here is my solution

Code:

WHEN DO [numvar:current time][=][game time] // Now use this if your game starts immediately.

If it doesn’t then use this at the point you want to start your timer:

Code:

WHEN[once] DO [numvar:start time][=][game time]
WHEN DO [numvar:current time][=][game time][-][numvar:start time]

This calculates the hours and minutes and seconds of elapsed time

Code:

WHEN DO [numvar:display hours][=][floor][(][numvar:current time][divided by][)]WHEN DO [numvar:display mins][=][floor][(][numvar:current time][divided by][)][modulo]
WHEN [numvar:display mins][<] DO [textvar:minzero][=]
…WHEN [else] DO [textvar:minzero][=][nothing] // this will display a 0 before the number if it is under 10WHEN DO [numvar:display sec][=][floor][(][numvar:current time][modulo][)]
WHEN [numvar:display sec][<] DO [textvar:seczero][=]
…WHEN [else] DO [textvar:seczero][=][nothing] // this will display a 0 before the number if it is under 10

This displays the time

Code:

WHEN DO [display][numvar:display hours][+][text: : ][+][textvar:minzero][+][numvar:display mins][+][text: : ][+][textvar:seczero][+][display secs][screen top center]

You can speed up your timer by multiplying it. So, for example you could have a world where if the player goes into the house to sleep time speeds up until he wakes up.

Code:

WHEN DO [numvar:current time][=][current time][multiplied by]

You could also link your timer to your sky box to create day and night at fixed intervals.

## Countdown Clock

To show the time as a countdown from a set amount of seconds use this code

WHEN [once] DO [numvar:maximum time][equals] // Put how many seconds you want your countdown to start from
WHEN DO [numvar:display time][equals][numvar:maximum time][minus][numvar:current time]

The code above is the same except you use [numvar:display time] instead of [numvar:current time]