Quick Actions and Slow Actions

Really a 2 part question.

  1. Wait: In zork wait advances the turn count by 3, unless something happens. How can I have the wait command advance the turn count further, but also stop if something happens. (IE Wait is 3 rounds, but if the pipe will burst in 2, it will stop when the pipe bursts).

  2. Examine: I would like the examine command to not advance the turn count at all, since it takes very little time to glance at an object, and I would hate the player to not examine anything during a timed puzzle.

So, I guess, how do I make various actions take a various number of turns, and how do I make the longer actions interrupt by outside forces?

I highly recommend Variable Time Control.

For various reasons, it’s not quite right for me, and I just completed a chunk of code for the first part of this. It’s not final by any means, but what worked for me was basically this:

  1. Create a new action (waiting for awhile)
  2. Classify all my scenes as urgent or nonurgent, and allow the player to know about urgent scenes or not
  3. It’s basically a big loop: for X turns, repeat through:
  • if an urgent known scene is happening, stop (or at least ask the player if she wants to stop)
  • otherwise, follow the turn sequence rules, or if you don’t have a reason to follow the turn rules, advance the time of day by a minute

From there, it’s just a matter of setting up which scenes are important enough to break actions for, setting checks for waiting during urgent scenes, and printing out text refusals to continue if necessary.

What I haven’t figured out is how to work this loop into more normal actions - if, say, I was taking 12 pens and something dramatic happened at turn 4, would I be able to stop with 3 pens? I’m basically ignoring that now, since most of the actions that will take a significant portion of time are ones I’m making, so it’s easy enough to do the loop myself. Otherwise, I ask the game to silently wait an appropriate number of turns after the action.

Variable Time Control is really clean in this way, and worth looking at. It’s lightweight and easy to use - I’d only recommend the alternative if you have no choice. (I’m not entirely sure where my code is incompatible with VTC - it’s definitely not working with McGravin’s Weather, and it’s not quite right with a couple other things I’ve done, but for smaller/less extension intensive projects it would be ideal.)

The I7 example “Timeless” shows you how to make an action take no game time (you interrupt the turn sequence rulebook with a “rule succeeds” command before the every turn rules fire in the turn sequence rulebook). The next example, “Endurance,” is supposed to show how to make different actions take different lengths of time, but it doesn’t look very useful for your purposes; maybe you want to do a loop that repeats the turn sequence rules but halts when something significant happens? That seems a little trickier to do.

(I’ve still got 5Z71; my documentation has the examples as no. 391 and 392 in section 18.17, but maybe it moved. Anyway, look for the turn sequence rules.)

…or that extension Gravel mentions sounds cool.

So here’s what I’m trying to do:

You’re a thief breaking into a building with a patrolling guard.

It takes 5 turns for you to pick the lock on the door.

If the guard can see you during his patrol during those 5 turns, that triggers one event.
However, if you successfully pick the lock and get in, you avoid that event.

If the guard doesn’t come, I’d like the game to just advance the time by the 5 turns, and play continues normally.

But if the guard comes at turn 1,2,3, or 4, that should trigger an event. (Spotted!)

Basically I need a way to tell my “every turn” rules that X turns is about to happen with no player input.

I want to make sure that when the guard spots you on turn 3, the game doesn’t assume you spend 2 more turns trying to pick the lock (or waiting).

I don’t think you actually need to increment the turn count in order to do that. You can write your ‘pick lock’ code in such a way as to calculate (or randomize) the arrival of the guard. It can all happen in a single turn.

If your guard is a patroller (moving one room per turn) then all you need to do is check what room the guard is now in, as part of the ‘pick lock’ code, and you’ll know whether or not he will arrive while the lock is being picked.


What you are describing is very similar to the way that WAIT 4 TURNS or WAIT UNTIL NOON commands that some of the Infocom games had. The game would automatically wait for you each turn, but stop waiting if something interesting happened. A couple of extensions implemented something like this for I6, I believe; you could check inform-fiction.org/extensions/time.html to see if there are any lessons to be learned there. Probably, though, there are enough differences in handling between I6’s daemons and I7’s every turn rules that the I6 extensions aren’t likely to be useful.

Anyway, moving on to I7: If your every turn rules are structured such that they will make no decision unless the guard finds you, you could do it like this:

At the Warehouse Door is a room.

Lockpicking is an action applying to nothing. Understand “pick lock” as lockpicking.

Instead of lockpicking:
let pick-turns be 5;
while pick-turns > 0:
abide by the every turn rules;
increment the turn count;
decrement pick-turns;
say “You succeed in picking the lock!”

An every turn rule (this is the guard searching rule):
if a random chance of 1 in 10 succeeds:
say “The guard caught you!”;
rule succeeds.[/code]

You could also do this without “abide” by checking the particular result of the every turn rules.

If this is glulx game, you might want to consider using the timer to make the fact that there is a delay clear to the player. The Real-Time Delays extension could be helpful with that: you could print some new text at the end of each turn on a given interval, for example.