version 1/100607 by Erik Temple
- Example: * The Chamber - A simple illustration of basic usage.
- Example: ** Teletype - Shows how to use real-time delays to mimic a teletype effect, with a short pause after each letter, and a longer pause after each line. The code here makes use of three global variables to set the speed for different types of output--delay for line breaks and paragraph breaks can be set separately from other characters. A few other phrases are included to show how common tasks such as changing the basic teletype rate can be made easier.
Real-Time Delays allows an author to request a delay of a given number of seconds. This delay occurs immediately, and no input or output can occur until the specified time has elapsed. It requires both Glulx Entry Points (built in) and Michael Callaghan's Fixed Point Maths extension.
The use of the extension is quite simple. The length of the delay is specified in milliseconds, e.g. 1000 represents one second. We may write a phrase such as
wait 1450 milliseconds before continuing
wait 14500 ms before continuing
at virtually any point in our source code. The delay is triggered immediately, and the action will not advance until the specified period has passed. However, we may tap the Return/Enter, Space, or ESC key at any time to immediately end the delay. To disable this for the Enter and Space keys, add "strictly" to the instruction:
wait 1450 milliseconds before continuing, strictly
The Escape key will always allow the action to continue, no matter which version of the phrase is used.
The extension will ignore calls to the real-time functions on interpreters that don't support them. If you'd like to subsititute an alternate effect on those interpreters, you can use this phrasing to fork between the two treatments:
if glulx timekeeping is supported
See the documentation for Glulx Entry Points for more information.