Glulx Input Loops

version 1/101121 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Section: The input loop setup rulebook

    The input loop setup rules are invoked at the beginning of the input loop, just before we put the game on hold while we wait for input. The most obvious thing to do here is to request a particular type of input, if necessary; the input event requested should be the focal event type of the input loop. Note that a Glulx input "request" merely prepares a window to receive a certain type of input; it is not the same as what this documentation calls "waiting for input," when the game is paused while waiting for the player to do something. Glulx input requests are for the most part not mutually exclusive--you can have hyperlink input pending in the same window that line input is pending, for example. (However, character input and line input *are* mutually exclusive. It is illegal to have these two types active at the same time.)

    If we need to reset any global variables that we are using in our input loop, the input loop setup rules are also a good place to do that.

    The input loop setup rules are a g-event rulebook, meaning that we can specify what focal event type they are associated with:

        An input loop setup rule for a char-event:

    This input loop setup rule will fire for any input loop whose focal event type is char-event, which works well and allows us to write generic code for all of our char-input loops. However, we may also want to include code that's specific to a certain loop. We can use the "current input loop" variable to specify a given loop:

        An input loop setup rule when the current input loop is character input:
        An input loop setup rule for a char-event when the current input loop is character input:

    Glulx Input Loops includes two input loop setup rules. The first is the "basic char input setup rule", which cancels line input and requests character input in the focal window of the current loop. This is usually something we will want for any character input loop, but it can of course be modified by delisting or replacing the rule.

    The other input loop setup rule supplied by Glulx Input Loops in the "suppress line input rule". This is run only for the main input loop, and all it does is suppress the main input loop's line input request if the focal event type of the main input loop has been set to something other than line input.