sassix
there are a couple issues with your file - you never save the OfflineTime variable, except for the first time it is run (when the local storage item is missing - and it is set to 0). And you don't really need to save that in local storage because the SavedTime is doing the same job.
Also, at the start of layout you check for the local storage items and then set the text fields before the items are finished loading from local storage.
And when a localstorage item exists, you set its value back to 0 instead of setting your global variables with the value from localstorage.
when you load items from localstorage, you don't know what order they will get loaded in, so you can't do any calculations until you are sure they have all been loaded. So, I changed it so that it calculates the time away when the SavedTime item is loaded and calculates the GoldEarned, but it doesn't add it to CurrentCurrency because that item may not have loaded yet. I only add it when you click the Quit button - where it sets the SavedTime and saves the new CurrentCurrency.
when you click the Quit button, it starts saving the localstorage items and then closes the browser. I wasn't sure it C3 would know to wait until the items were saved before closing down - and it seemed like the values didn't get saved once or twice in testing, so I made it wait until the items finished saving before quitting.
https://www.rieperts.com/games/forum/AwayTimeFix.c3p