Glulx Input Loops

version 1/101121 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Section: The main input loop

    In addition to creating our own loops, we can also specify much of the behavior of Inform's main input loop (both the focal event type and the focal window, in fact). However, we cannot invoke the main input loop ourselves. This is because the main input loop is actually the I6 routine VM_ReadKeyboard, and is intimately embedded with other library routines (see the template layer documentation for more information).

    The main input loop in Inform accepts standard typed input--"line input" in Glulx parlance. We can, however, change that simply by specifying the "focal event type" of main input:

        The focal event type of main input is hyperlink-event.

    The main input loop will now be considered to be looking primarily for hyperlink input; line input will not be requested. Note that we are responsible for requesting input for these loops. To continue the hyperlink example, if we are using the hyperlink functionality built into Flexible Windows (or using certain other extensions, such as Inline Hyperlinks or Basic Hyperlinks), hyperlink input will be requested automatically by those extensions and we need not worry about it. If we are in a situation where we need to request input ourselves during the input loop, we can do so in the "input loop setup" rulebook; see below.

    The main input loop should result in text being entered as the player's command. We can do this in the "input loop event-handling" rulebook, which runs immediately after input is received, or in HandleGlkEvent, the I6 routine that is hooked into by the Glulx Entry Points extension. See below for more on this, as Glulx Input Loops provides a somewhat more flexible I7 implementation of HandleGlkEvent that allows any event to produce a command. The "No Typing Allowed" example replaces the standard line input with hyperlink input.