0 votes

Hi everyone,

I have a clock set up showing the OS's hours, minutes and seconds. What I need is an event (maybe a signal) to trigger on every tick of the OS-time's second.

Or: have a trigger (a button-press) yielded until the next OS-time second tick.

Im working on a backwads-running timer, showing the remaining time until that entered by the user. Calculating the remaining seconds I can have that timer start immediately, but as it should reach 0 exatly when the time is reached, I need it to start with the next clock-second...

The docs show get_system_time_secs, which seems promising, but I wouldn't get anything working with it. Any suggestions?

Godot version 3.2.3
in Engine by (365 points)

2 Answers

0 votes
Best answer

Thanks to golddotasksquestions on reddit for this:

"trigger something repeatedly every second, in sync with OS-time-second"
Like print "X" every second, in sync with OS time.

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")
    last_second = time.second
    print(time.second)
by (365 points)
0 votes

I don't think this is possible right now in Godot since normally people just use timers for this. But you can suggest it on the proposals GitHub.

by (7,190 points)

It basically boils down to having a timer running in sync with the OS-time...

A built-in function for a timer-countdown towards a time and date, maybe even years away, would indeed be cool, wouldn't it? ("2y, 3m, 1w, 4d, 17h, 25min, 39sec to go...")

EDIT:
So yes, I'm trying to have my timer start exactly when the next OS-time-second kicks in.
For now I'm thinking of "compare the entered time with the OS-time and fire when they match". I'll see how this could be done and be back when I found a way...

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.