Glulx Entry Points by Emily Short


Please note that this extension is provided as a framework and as a basis for other extensions. Thanks to Eliuk Blau and Jon Ingold for pointing out some bugs in version 5, and to Erik Temple for the patch handling input cancellation that brings us to version 7.

Version 10/200602 was a trivial patch by Gavin Lambert to avoid the use of deprecated phrases within the extension itself, fixing compatibility with "use no deprecated features".

Chapter: Events

Glulx allows the author to set responses to certain events:

Timer - event repeated at fixed intervals
CharInput - keystroke input in a window
LineInput - full line of input in a window
MouseInput - mouse input in a window
Arrange - some windows sizes have changed
Redraw - graphic windows need redrawing
SoundNotify - sound finished playing
Hyperlink - selection of a hyperlink in a window

As of version 10, Glulx Entry Points provides a rulebook, the "glulx input handling rules" so that the author can add responses to the these events without himself having to include any Inform 6 code. The glulx input handling rules is a parameterized rulebook, meaning that the author can specify which event or events a given rule responds to by specifying a kind of value, the "g-event". The g-events corresponding to the events types described above are:

timer-event
char-event
line-event
mouse-event
arrange-event
redraw-event
sound-notify-event
hyperlink-event

It is also possible to refer to groups of g-events using adjectives. Two adjectives are provided, though the user could of course create more. These are:

independent of the player - includes timer events, sound notification events, arrange events, and redraw events.
dependent on the player - includes all other events, i.e. the events that can only happen due to player input.

We can get basic information about the last event handled using these phrases:

current glk event - the g-event type last handled.
window of the current glk event - if the last event was associated with a window (char-event, line-event, mouse-event, or hyperlink-event), this contains the number of the window's glk reference.

The glulx input handling rulebook replaces the set of eight rulebooks defined in versions of Glulx Entry Points previous to version 9. These rulebooks, listed below, should be considered deprecated and may be removed in a future version of the extension, but for now they will still work just as they did in past versions:

The glulx timed activity rules is a rulebook.
The glulx redrawing rules is a rulebook.
The glulx arranging rules is a rulebook.
The glulx mouse input rules is a rulebook.
The glulx character input rules is a rulebook.
The glulx line input rules is a rulebook.
The glulx sound notification rules is a rulebook.
The glulx hyperlink rules is a rulebook.

If you are certain that you do not need these rulebooks in a project (i.e., you are not using extensions that employ them), you can stop Inform from calling them by declaring the use option:

Use direct event handling.

Chapter: Replacement Commands

One of the things we may want to do -- especially with mouse input or hyperlinks -- is generate a command for the player. To do this, we set the value of Glulx replacement command to whatever string of text we want to turn into the player's command. If we do this, Inform will treat whatever command we issued in "Glulx replacement command" as though the player had typed it at the command prompt. The extension Basic Hyperlinks builds on this infrastructure and provides an example of how to make use of these features.

Because the Glulx replacement command is indexed text, it is possible to build on to the string automatically, if for some reason we need to auto-generate our recommended commands.

Section: A Note on Sound Support

Currently Inform is not designed to support sound output properly across all systems. The Mac OS X IDE will not play sounds in-game, so if we are developing a sound-rich game on the Mac, we will need to test the sounds by releasing the game file and playing it on a separate interpreter; at the time of writing, the best Mac sound support was provided by Gargoyle.

Chapter: Useful Phrases

Two phrases that may be useful to those working with Glulx input/output are provided:

update the status line - calls the Inform library's routine to refresh the status window
print prompt - calls the Inform library's routine to print the command prompt

Example: * Input Handling - Very basic use of the glulx input handling rules. Shows how to detect events according to whether they are generated by player input, how to override the player's typed input with a replacement command, and how to use the "current glk event" phrase.

Include version 10 of Glulx Entry Points by Emily Short.

Use direct event handling.

Glk Testing is a room.

Glulx input handling rule for an independent of the player g-event:
say "[bracket]Non-input event detected: [current glk event][close bracket][line break]".

Glulx input handling rule for a dependent on the player g-event:
     say "[bracket]Player input detected: [current glk event][close bracket][line break]".

Glulx input handling rule for a line-event:
     now the Glulx replacement command is "jump".

Example: * Working Without Sound - Printing a warning at the beginning of the game if the interpreter does not use sound.

"Working Without Sound"

Include Glulx Entry Points by Emily Short.

Include Basic Screen Effects by Emily Short.

First when play begins:
     unless glulx sound is supported:
         say "This game uses sound effects extensively. The interpreter you're using is unable to play sounds, so you will be missing part of the intended experience.

Would you like to continue anyway?";
         unless the player consents:
             stop game abruptly.

Royal Albert Hall is a room.

Test me with "listen".