Hello, I'm making an idle clicker game for cell phones, I have everything ready except the AFK production.

My idea is to take the current system time every 2 seconds automatically to have the information when the game closes, I also take the time when starting the game, comparing the last closing time with the current one (opening), subtract both to obtain the difference in seconds and thus multiply it by the production per second.
I've been using: Time.get_unix_time_from_system() for my tests, but I feel like it's wrong

How can I print the separate time?
example: 00:00:00 Hour, minute and seconds

And how do I get the system time and transform it into seconds?

DaveTheCoder
How can I print the separate time?
example: 00:00:00 Hour, minute and seconds

And how do I get the system time and transform it into seconds?

  • Toxe replied to this.

    How can I print the separate time?
    example: 00:00:00 Hour, minute and seconds

    Do you mean: convert elapsed time in seconds to elapsed time in hours/minutes/seconds? That's the kind of question that ChatGPT is good at answering, although you often have to tweak the result.

    Me:

    Please provide Godot GDScript code that takes elapsed times in seconds and converts it to hours, minutes and seconds.

    ChatGPT:

    func convertTime(seconds):
        var hours = int(seconds / 3600)
        var minutes = int((seconds % 3600) / 60)
        var remainingSeconds = int(seconds % 60)
    
        print("Hours: ", hours)
        print("Minutes: ", minutes)
        print("Seconds: ", remainingSeconds)
    
    # Example usage:
    var elapsedTimeInSeconds = 3665  # Replace this with your elapsed time in seconds
    convertTime(elapsedTimeInSeconds)