How to compare the time of when i leaved (the last time) the game with the current time

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By jvnq1992

I am making a idle game i want to make a offline progress system like all idle games but i dont know how i compare and i dont know how calculate it for the player get the money

:bust_in_silhouette: Reply From: jgodfrey

A simple way would be to use the result of Time.get_unix_time_from_system() as your base time value. That’s a value representing “elapsed seconds” since the Unix epoch time (Jan 1, 1970). It’s easy to manage as it’s just an integer value. So, if you store that value when someone quits your game, and you get a new copy of that value when the game starts, you’d have two points in time, each represented by an integer value.

From there, simply subtracting the first value from the second results in the number of real-time seconds that have elapsed between those two time stamps. Using that value, you can do whatever is appropriate in your game.

Ok i will test later

jvnq1992 | 2023-02-12 16:39

Thanks man worked

jvnq1992 | 2023-02-12 17:03

this will be useful to me

Cyber-Kun | 2023-03-06 20:25

1 Like