Glulx Input Loops

version 1/101121 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Section: The input loop event-handling rulebook

    The input loop event-handling rulebook is called immediately after an event is actually received. This event could be either input from the player, or one of the non-input events (such as a timer event or a sound notification event).

    The input loop event-handling rules replace the library (as opposed to the author-provided) phase of event-handling as described in step 3 of the flow described in the "Basics of Input Handling" section above. They can be used for preliminary input handling (for example, to set variables that we will later handle using the rulebooks provided by Glulx Entry Points), or they can be used for complete input handling. This will more often than not be a matter of style, but one rule of thumb might be:

        Use the input loop event-handling rules for behavior that pertains only to a certain input loop, while using the Glulx Entry Points rulebooks for behavior that would apply regardless of the loop.

    It is also possible for the input loop event-handling rules to decide that the Glulx Entry Points rulebooks should be skipped, so keep that in mind as well; this is done using a named rulebook outcome.

    There are three named outcomes that we may use in the input loop-event handling rulebook that can help to direct the flow of events. These are:

        continue input loop processing (failure)
        stop input loop processing (success)
        delay input handling (success)

    Each of these does something different. See the discussion below for more information.

    The input loop event-handling rules are, like the input loop setup rules, a g-event based rulebook, but the g-event specified is not the focal event type of the input loop. Instead, the input-handling rule preamble refers to the actual event that was received. To handle a hyperlink event, for example, we can do these types of things:

        An input loop event-handling rule for a hyperlink-event:
        An input loop event-handling rule for a hyperlink-event when the current input loop is character input:

    Should we need to know what the last received event was outside of the input loop event-handling rules, we can test--but not assign--it using the "current glk event", e.g. "if the current glk event is char-event".

    Glulx Input Loops provides three input loop event-handling rules. The first two of these redraw the status line immediately when the window is resized, whether by the player's explicit command (arrange-event), or due to some other factor, such as the monitor resolution being changed (redraw-event). These rules are:

        update status line on arrange rule
        update status line on redraw rule

    There is also a rule that fires when character input is received, but only when the focal event type of the input loop is character-event. All that this rule does is issue the "stop input loop processing" rulebook outcome, to ensure that the event completes the loop. This is the

        basic char event handling rule