I’m working on a story, and would like to measure how long the player lingers in terms of seconds (or other real-world-time) rather than in turns. To be clear, I mean actual time elapsed since the player issued a command, not merely in-universe time expressed in minutes. Is there a way to do this? All the documentation relating to timers I’ve found so far refers to timers that count down to fire an event after so many seconds, rather than count up to determine how long it has been since and event fired, which is what I require.
I did find an extension that supposedly allows me to reference the total time elapsed since the program started, so this sort of functionality would seem to be possible in glulx, but I don’t know how to do it. Any ideas? At the moment I suppose I could try cobbling something together from repeatedly grabbing the total time elapsed, but there must be a more elegant way.
This is a feature I recently added in Glulx, but it isn’t necessarily available in all interpreters yet.
One extension is inform7.com/extensions/Ron%20New … index.html
…but it looks like that doesn’t do exactly what you want.
This would work, mostly:
To decide if the player's timestamp is available: (- (glk($0004, 20, 0) ~= 0) -).
To decide what number is the player's timestamp: (- glk($0161, 1) -).
Instead of jumping:
unless the player's timestamp is available:
instead say "Not available.";
let N be the player's timestamp;
say "It is [N]."
You can grab the player’s timestamp at any point (say, every turn) and subtract for the difference.
The only catch is that the value is a 32-bit number, so it’ll overflow sometime in the year 2106. If someone is playing your game on that day, the timer will go wrong once.
Wow, that is fantastic, thank you! That should definitely do the trick, (so long as I finish writing the thing sometime before 2106!)