Text Window Input-Output Control

version 2 by Erik Temple

  • Home page
  • Beginning
  • Previous

  • Example: ** Terminal - This example illustrates one use for changing the current text output window. Basically, the player must interact with a computer terminal, and during this interaction the game's interface apes the terminal. We open a new window (the terminal-output-window) in front of the main window, covering the latter completely. This new window is a text-grid window with reversed color-scheme and monotype font (both defaults for text-grid windows).

    Another point of interest might be the "To say terminal text" phrase, which shows how to write text *only* to the transcript, and not to the screen. We do this here because we are using the status line (also a text-grid window) to display the name of the terminal. Since the I7 library (for good reason) doesn't write the status line to the transcript, we stream this text to it manually.


        Include Basic Screen Effects by Emily Short.
        Include version 1 of Text Window Input-Output Control by Erik Temple.

        The terminal-input-window is a text-grid g-window spawned by the main-window. The position is g-placebelow. The measurement is 10.

        The terminal-output-window is a text-grid g-window spawned by the main-window. The position is g-placeabove. The measurement is 100.

        Before printing the command prompt when the location is TERM:
            clear the current text input window.

        [The following two rules restore the default behavior of the yes-no prompt.]

        When play begins:
            change the yes-no prompt to "".
        Yes-no prompting:
            say "[run paragraph on]";
            rule succeeds.

        The Control Center is a room. "Ancient machines sputter, buzz, and whine. How are they still operational after so many eons?"

        The terminal is a device in the Control Center. It is switched off. It is fixed in place.

        Instead of switching on the terminal:
            say "The terminal flickers to life. [paragraph break]Please press any key.";
            wait for any key;
            clear the main-window;
            move the player to TERM;
            open up the terminal-input-window as the main text input window;
            open up the terminal-output-window as the main text output window;
            change the right hand status line to "";
            say terminal text;
            say "WAKING...[paragraph break]RUNNING DIAGNOSTICS[paragraph break]SYSTEM CHECK OK[paragraph break]--------------[paragraph break]";
            say terminal selection;
            now the terminal is switched on;[we do this manually since we are bypassing the standard behavior of the switching on action with this instead rule.]
        Procedural rule when the location is not the Control Center:
            ignore the room description heading rule;
            ignore the advance time rule.
        To say terminal text:
            if we are writing a transcript:
                say "[echo stream of current text output window][line break]----[location]----[line break][stream of current text output window]"
        Rule for constructing the status line when the player is not in the Control Center:
            center "[location]" at row 1;
            rule succeeds.
        To say terminal selection:
            say "MAKE SELECTION:[paragraph break]1. ACCESS CONTROL PROGRAM[line break]2. EXIT[paragraph break]"

        TERM is a room. The printed name is "TERMINAL 42.54.1".

        Every turn when the location is TERM:
            say terminal text.
        After reading a command when the location is TERM:
            if the player's command does not match "[number]":
                reject the player's command.
        Entering terminal commands is an action applying to one number. Understand "[number]" as entering terminal commands when the location is TERM.

        Carry out entering terminal commands:
            if the number understood is 1:
                clear the current text output window;
                say "*****************[line break]* ACCESS DENIED *[line break]*****************[paragraph break]";
                say terminal selection;
            otherwise if the number understood is 2:
                clear the current text output window;
                say "********[line break]* EXIT *[line break]********[paragraph break]HIBERNATING...";
                wait for any key;
                shut down the terminal-output-window;
                shut down the terminal-input-window;
                say "The terminal flickers off. Guess you'd better hunt for a password. (Well, really, that's for a different game--this is just a little demo...)";
                move the player to the Control Center;
                change the right hand status line to "[score]/[turn count]";
                now the terminal is switched off;
                rule succeeds;
                reject the player's command.