intfiction.org

The Interactive Fiction Community Forum
It is currently Sun May 26, 2013 2:23 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon May 21, 2012 9:02 pm 
Offline

Joined: Mon May 21, 2012 8:54 pm
Posts: 2
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.


Top
 Profile Send private message  
 
PostPosted: Mon May 21, 2012 10:08 pm 
Offline

Joined: Sat Jan 23, 2010 4:56 pm
Posts: 2087
This is a feature I recently added in Glulx, but it isn't necessarily available in all interpreters yet.

One extension is http://inform7.com/extensions/Ron%20New ... index.html
...but it looks like that doesn't do exactly what you want.

This would work, mostly:

Code:
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.


Top
 Profile Send private message  
 
PostPosted: Mon May 21, 2012 10:27 pm 
Offline

Joined: Mon May 21, 2012 8:54 pm
Posts: 2
Wow, that is fantastic, thank you! That should definitely do the trick, (so long as I finish writing the thing sometime before 2106!)


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group