I've made a simple clock for anyone that wants to use it.
It displays a digital time, and can be manipulated by adding or subtracting the variables $hours and $minutes.
I'm not sure if there was a better way of doing this, but I've made a simple clock for anyone that wants to use it.
It could probably be made fancier with font stylings, but serves a purpose as is, so I thought I'd share.
Sample attached.
<<nobr>><<if $hour >12>><<set $hour to ($hour-12)>><<endif>>
<<if $minutes >59 >><<set $hour to ($hour+1)>><<set $minutes to ($minutes - 60)>><<endif>>
the time is <<$hour>>: <<if $minutes is 0>>00<<else>><<$minutes>><<endif>><<endnobr>>
I have also attached a virtually identical 24 hour clock. For reasons I cannot work out, it has a minor glitch when it reaches midnight- the clock on the menu displays correctly ("the time is 0:00") but the same words embedded in the passage don't calculate, and displays as 24:00. (This is fixed on the next click, may matter very little to others, but is stil frustrating)
Comments
I think a real clock skips 2400 and goes right to 0000.
11:59-12:00-12:01
2359-2400/0000-0001
I compiled using Twine 1.4.1, found the same glitch on IE8 and Chrome. It's functional for my purposes (will be using it in the StoryMenu space).
It's doing that because you have your order of operations wrong. This is the current
24clock
passage: If you push the hours past 23, it works as intended. However, if you push the minutes past 23:59, then you see odd behavior you've noticed. That's because modifying the minutes can alter the hours, but the check to see if the hours have exceeded 23 has already been done by that point, so minute modifications can drive the hours past 23 (which won't be corrected until<<24clock>>
is called again).Simply swapping the order of the
<<if>>
statements will fix the issue. For example: