Basic Real Time by Sarah Morayati


Basic Real Time is a wrapper for Glulx's real time functions. The extension requires Glulx Entry Points by Emily Short. It also requires you, of course, to compile to Glulx (not. z5 or. z8).

This extension differs from the author's original version: it has been modified for compatibility with version 6L02 of Inform. The latest version of this extension can be found at <https://github.com/i7/extensions>.

This extension is released under the Creative Commons Attribution licence. Bug reports, feature requests or questions should be made at <https://github.com/i7/extensions/issues>.

The original author can be contacted at: morayati (at) email (dot) unc (dot) edu

Normally, Inform 7 games are turn-based: that is, events happen, and time passes, only when the player inputs a command.

Glulx allows the inclusion of real time events: events that happen based on time in the "real world".

This extension uses the Glulx timer, which normally repeats events at regular intervals. Here, the event will fire only once, when the timer is finished.

Once the timer runs out, the event will fire after the player's next turn (this is to avoid interfering with the command prompt.)

Usage:

start timer for (number) second/seconds;

Starts the timer. Once the action fires, the timer automatically stops.

set timer for (number) second/seconds;

Changes the time remaining to a specific amount.

deduct (number) second/seconds from timer;

Deducts time from the timer.

add (number) second/seconds to timer;

Adds time to the timer.

pause timer;

Pauses the timer.

resume timer;

Resumes the timer.

stop timer;

Stops the timer manually.

say seconds remaining;

Prints the amount of seconds remaining; can be called in quotes:

.

say seconds elapsed;

Prints the amount of seconds elapsed; can be called in quotes:

.

A glulx timed activity: perform the next real-time action;

Triggers the next action. It will fire on the next available turn.

The next real-time action is a stored action which can be altered in a story's source code, first when play begins, then each time the author starts the timer:

now the next real-time action is the action of...

As with any other stored action, this can either be an action built into the standard Inform 7 library or a new action defined by the author.

The latter in particular gives versatility; the author can schedule, in real time, anything that can be defined as a result of an action.

Example: * "Green Button" - Starting, stopping, and altering the timer.

"Green Button"

Include Basic Real Time by Sarah Morayati.

The story headline is "An interactive panic button".

Control Room is a room. "It's your first day on the job at Technologies and they've already got you in charge of all the controls. Your boss didn't tell you what all these buttons and switches were for. All she said was to press the green button, and that there would be severe consequences if you pressed the red button. (The exact word she used was 'fired.')"

When play begins:
     now the next real-time action is the action of releasing the terrors;

The gadgets are scenery in Control Room. They are plural-named. Instead of doing something to the gadgets, say "There are too many of them and they're too intimidatingly gray. You don't even know where to begin." Understand "buttons" and "button" and "switches" and "switch" and "control" and "controls" as the gadgets.

The green button is scenery in Control Room. The green button can be pressed or unpressed. It is unpressed. The description of the green button is "It's an enticing pale green and has 'YES' splayed across it in white lettering."

Instead of pushing the green button for the first time:
     now the green button is pressed;
     now the description of Control Room is "It's your first day on the job at Technologies and they've already got you in charge of all the controls. Your boss didn't tell you what all these buttons and switches were for. She also didn't tell you that pressing the green button would release world-rending terrors. Oops.";
     start timer for 15 seconds;
     say "You press the green button. Almost immediately, a pleasant female voice (you briefly wonder why they're never male, or horrifying) intones, 'Green button pressed. Releasing world-rending terrors in [seconds remaining] seconds.'";

Instead of pushing the green button:
     deduct 1 second from timer;
     say "You jab at the green button. The voice intones, 'Thank you for your impatience. The world-rending terrors will be released one second sooner.' Your boss left this part out.";

The red button is scenery in Control Room. The description of the red button is "If the fact that it was bright red wasn't warning enough, the text reads 'NO' in bold letters."

Instead of pushing the red button:
     if the green button is unpressed:
         say "You just got this job. Clearly what you should do is disobey a direct order. Clearly.";
     otherwise:
         stop timer;
         say "You debate the relative merits of remaining employed versus dealing with world-rending terrors, figure you'd rather lose your job than your life, and press the red button. The voice, no longer so pleasant, whines 'No world-rending terrors will be released. I hope you're happy.' Huh. Guess that was the world-rending-terror-ending button. You wait for your boss to walk in, a trapdoor to appear below you, or a big boot to kick you out the window, but apparently it isn't a day for cartoon tropes. Huh. Maybe you'll be OK after all.";
         end the story finally saying "You have saved the world";

Releasing the terrors is an action applying to nothing.
Carry out releasing the terrors:
     say "You're no good at keeping time, so you're a bit startled when that voice intones: 'Releasing world-rending terrors now. Have a nice day.' What conspires next is too terrible for words. Good thing, really, because you no longer have a way to speak them.";
     end the story saying "You have died";