I was wondering if it might be possible to write some code that will track how long a user spends in the game, and report that amount of time at the end (as in, a final congratulations screen telling the user various stats including time taken.)
I tried adding:
(set: $gamestart to (current-time: ))
to my startup passage, and
(set: $gameend to (current-time: ))
to the final passage, thinking that I could just subtract to get the amount of elapsed time.
However, it seems that these variables are being saved as strings rather than numerical values, and I am not clever enough with Harlowe coding to know how to convert datatypes.
Is there any way to do this, or is this just an idea I should abandon?
There’s the (number:) macro https://twine2.neocities.org/#macro_num that allows to change a string to a number. However the format of the string will comprise letters or other signs, like ‘:’ or ‘am’/‘pm’, so it will need some coding to achieve any result. And if the user needs more than one session, you won’t be able to track time this way.
Thank you both so much! I’ve gone with the second option as it seemed much simpler - I can see how complicated my original idea was, lol. Thanks a million for pointing me to the time keyword and also to the simpler link-reveal-goto macro (I can tell already that they’ll both be very useful!)