Hi, I would like to display a digital clock in my project.
I’ve made a text object with this value: ToString(Time("hour"))+":"+ToString(Time("min"))
However the minutes from 0 to 9 have no leading “0”, so I get values like 8:0 and 16:1.
Thank you Markus_Schuetz.
I don’t know Javascript, so I’ll wait some time to see if anybody answers with a simpler solution.
I don’t really think it will happen, so probably I’ll use your code (I think I’ll be able to do it with guides like this), so thank you
Hi, there’s at least another solution that doesn’t involve Javascript or external event. But I would not call it easier. I used it before because I don’t know Javascript
The thing is to have a text variable “zeroornot” set at the beginning of the game, like this :
zeroornot.0 = “0”
zeroornot.1 = “”
zeroornot.2 = “”
zeroornot.3 = “”
zeroornot.4 = “”
zeroornot.5 = “”
The following expression will return “0” if Time(min) <10, else it would return nothing ("") :
zeroornot[ToString(Floor(Time(“min”)/10))]
So you just have to add it in your time display text :
Extending @Markus_Schuetz’s solution, here’s a simple way using JavaScript. It sets the scene variable formatted_time, creating the variable if it doesn’t already exist :