by LadylexUK
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?
Answer:
The answer given used countdown timers and didn’t use the inbuilt gametime tile. So here is my solution
Code:
If it doesn’t then use this at the point you want to start your timer:
Code:
WHEN DO [numvar:current time][=][game time][-][numvar:start time]
This calculates the hours and minutes and seconds of elapsed time
Code:
WHEN [numvar:display mins][<][10] DO [textvar:minzero][=][0]
…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][60][)]
WHEN [numvar:display sec][<][10] DO [textvar:seczero][=][0]
…WHEN [else] DO [textvar:seczero][=][nothing] // this will display a 0 before the number if it is under 10
This displays the time
Code:
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:
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][240] // 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]