Display a timer

As time
You can display a timer in multiple ways thanks to the [as time] tile after a number. You can then specify the format using modifiers among [racing style], [12 hour clock style], [in days/hours/minutes/seconds/milliseconds].

Making a timer from scratch
Here is some kode for a basic countdown clock: Code: 1. WHEN [duration timer] [GameLengthInSecs] DO 2.   WHEN DO [Minutes] [=][floor][(][timer seconds remaining][divide by] [60] [)] 3.   WHEN DO [Seconds] [=][floor][(][timer seconds remaining][modulo] [60 ][)] 4.   WHEN [Seconds] [<] [10] DO [display][screen top right] [Minutes] [+] [:] [+] [0 ][+] [Seconds] [x-large] 5.      WHEN [else] DO [display][screen top right] [Minutes] [+] [:] [+] [Seconds] [x-large] 6. WHEN [countdown timer] [GamelengthInSec] DO [switch page] [Game Over] key: [blue] = user defined variable   [red] = values defined Fairly straight forward. It uses a duration timer to control the length of the countdown on screen and uses [timer seconds remaining] to calculate timers display values. [timer seconds remaining] is a value only available within a timers scope and is found in [output] folder. The actual display is slightly complicated by that fact the PS default display on screen does not have leading zeroes. e.g 1 minute and 9 secs without the zero looks like 1:9 and that just looks wierd, we want 1:09. So on line 4 for values less than 10 you display the zero explicitly.

NB the reason that the countdown is not to control the on screen timer is because it only executes the once! So I needed both a duration and countdown.

To make this into a timer going up in value you could just replace [timer seconds remaining] with [time seconds completed], but this has restrictions in that the timer will eventually end, I have not tested putting huge number in duration but that may work

To make an open ended timer will require slight restructuring. Code: 1. WHEN [once] DO [GamelengthInSec][=] [0] 2. WHEN [countdown timer] [1] [loop] DO [GamelengthInSec] [increment by] [1] 3.   WHEN DO [Minutes] [=][floor][(] [GamelengthInSec] [divide by] [60] [)] 4.   WHEN DO [Seconds] [=][floor][(] [GamelengthInSec] [modulo] [60 ][)] 5. WHEN [Seconds] [<] [10] DO [display][screen top right] [Minutes] [+] [:] [+] [0 ][+] [Seconds] [x-large] 6.   WHEN [else] DO [display][screen top right] [Minutes] [+] [:] [+] [Seconds] [x-large] key: [blue] = user defined variable   [red] = values defined with no fixed duration its necessary to count the passing of time, line 1 and 2 set up a variable holding the number of seconds elapsed and incrementing it by 1 every time the countdown timer triggers, it is defined to trigger once every second. NB this too can be used to do countdowns i.e. change line 1 to set countdown duration and change line 2 to decrement the value.