Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Keeping a running clock

edited September 2015 in Help! with 2.0
I am building a text adventure that requires the passage of time. I have already built a system for a "Nap" passage that works like so.
<!-- $time is time of day, in minutes, so 1200 is eight in the evening
(since it's 1200 minutes since midnight).

Before you ask, I already have a modular function that resets the clock at midnight
so I don't have ridiculous times like "127:33". -->

|wake>[Wake up]

<!-- This line runs as the user is leaving -->
(click: ?wake)[(set: $time to it + (round: (time / 100)))(goto: (history:)'s last)]

However, it would be nice if I could put code in a footer (which I already have) that automatically adds the amount of time spent in that window to the in-game timer. I already tried using a universal (click:) function, but that doesn't work. Any ideas?

Comments

  • There are a number of issues with using real-world time within a game, two of them being: 1. People read at different speeds; 2. People get distracted by real-world events.

    But to answer your question, Harlowe has a timer macro named (live:) which you could use to update your $time variable.

    Ex. If you want something to happen roughly every minute you would do the following:
    (live: 60s)[
    Put the code you want to happen roughly every minute here.
    ]
    
    .... I said roughly every minute because it may take slightly longer that the time delay you supplied to fire because the program may be doing something else at the time of the firing like switching between passages, updating the screen, etc...
  • That answered my question perfectly; in fact, I think I'm going to use that for my nap thing so people can keep track of time.

    By the way, one of my favorite interactive fictions, A Dark Room, is heavily dependent on the passage of time, so it's not universally evil.
Sign In or Register to comment.