A TADS3/adv3 module providing an in-game timestamp-like service

This is another one where I’m not sure how useful it’ll be to anyone else. This is a T3/adv3 module that provides a singleton that keeps track of an in-game “timestamp” that consists of the turn number plus a serialization counter (for cases where multiple things happen in a turn and the order needs to be tracked). Here: timestamp github repo.

Basic usage is that code can use gTimestamp to obtain the current (at the time of calling) timestamp in the form of a Timestamp object. It provides a number of methods for working with timestamps, i.e.:

     // Save the current timestamp
     local ts0 = gTimestamp;

…and then elsewhere…

     // Check if the saved timestamp matches the current timestamp
     if(ts0.isEqual(gTimestamp)) {
          // do stuff
     }

There’s also a macro to handle this specific case, which is:

     // Same as ts0.isEqual(gTimestamp)
     if(gCheckTimestamp(ts0)) {
     }

Actions that want to advance the timestamp counter (without changing the turn number) can call gBumpTimestamp.

There’s also a gDuration macro that returns the difference between the current timestamp and a given timestamp:

     // delta will contain the difference between the current timestamp
     // and ts0
     local delta = gDuration(ts0);

All of this is in support of the rule engine/state machine/scene stuff I’ve been working on, which has been using the turn counter to figure out when it has to re-compute stuff. It turns out that this was breaking in slightly unpredictable ways for system actions (which don’t advance the turn counter by default) and some other cases where actionTime is not 1.

4 Likes