![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | pferft |
Hi everyone,
each second, my RichTextLabel adds +1.
extends RichTextLabel
var hour = 0
var minute = 0
var second = 0
var last_second = OS.get_time().second
func _process(delta):
var time = OS.get_time()
if time.second != last_second:
print("start of a new second")
text = str(int(text) + 1)
last_second = time.second
But instead of showing that increasing number, I would like it to be displayed as a timecode like hh:mm:ss
I believe I’d need to somehow translate that number into something like this:
set_text("( %02d:%02d:%02d )" % [hour, minute, second])
or maybe this:
set_text("( %02d:%02d:%02d )" % [fmod(hour/3600, 24), fmod(minute/60, 60), fmod(second, 60)])
but I can’t quite find a way to achieve this. Any ideas?