How do I create a game timer?

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:

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][3600][)]WHEN DO [numvar:display mins][=][floor][(][numvar:current time][divided by][60][)][modulo][60]
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:

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][10]

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]

Comments are closed.

Website Powered by WordPress.com.

Up ↑

<span>%d</span> bloggers like this: