I’ve finally come to the end of a rather quixotic quest. A strange bug bit me while I was finishing up the main Glimmr package a few months back: I wanted to leverage Glimmr’s capabilities to create a relatively easy way for authors to offer HTML-style form fields within an IF game. Why on earth did I want to do that? Not for any good reason; in fact, I still haven’t come up with a practical IF-related use for it that would justify the hours it eventually took from me! Other than perhaps to remake Bureaucracy (see image below for a form from that game).
In the end, I had to create two extensions to accomplish this goal: Glimmr Form Fields and Glulx Input Loops. (If you’re curious about the form fields, you can download compiled example games here; this will let you see how it works without firing up Inform 7, installing dependencies–of which there are many–etc. See the note about interpreters below.) A short discussion of how the one led to the other follows.
The basic mechanics for graphic form fields were easy and I was able to put a prototype together in just a few hours. I had good, general-purpose yet customizable ways to control text entry into the field, the backspace key, moving the cursor within the field, and so on. This rested (and still rests) on a couple of subterfuges: First, of course, the “text” in the form fields is not actually text but individual letterform graphics strung together to form words. Second, one doesn’t type really anything “into” the text fields; instead, we are receiving per-character input in the main text window and converting that for display in the graphics window.
It was the latter that caused me real headaches. Not because it was difficult to create something basic, but because I wanted the user (player) to be able to interact with multiple fields, clicking on one to type and then clicking on another to enter text there. Inform’s built-in input routines are very simply structured, and this turned out to be a sticky problem: Multiple fields easily led to nested loops that would quickly crash the program, or lead to other difficulties.
So, I had to make a bit of detour, and get an education in the finer points of Glulx input and Inform 7‘s (and Inform 6’s) implementation of input (special thanks to Zarf, the creator of Glulx, for his help–and patience). In the end, I decided to more or less rewrite the library input routines. Without going into great detail, the Glulx Input Loops extension gives the author many more hooks for decision-making within the overall “loop” of input to action-processing. It also introduces named input loops, as well as the idea of the “secondary” input loop, which shares input-handling with the “primary” loop; this goes a good way toward preventing the kinds of nasty nesting problems that can result when some types of input spawn new requests for input.
The new hooks provided by Glulx Input Loops let me complete Glimmr Form Fields as I wanted, avoiding the issues with event nesting. Glulx Input Loops also resulted in the keystroke input experiment I posted a month or so back. I hope that it proves to be a useful extension, and I think it will, particularly to those experimenting with alternate input paradigms.
I’m still asking myself why I dedicated myself to implementing form fields, though. The end result is pretty neat, but its neatness is not really IF-related… Who knows, maybe someone will think of something to do with it; the tool is there, at least. In the meantime, if you have your any ideas for using Glimmr Form Fields in IF, please feel free to leave a comment below–I’d love to hear that someone might actually get some use out of it!
A note for Mac users who might want to check out the Glimmr Form Fields compiled examples: If you are using a Mac, you probably default to using Zoom or Spatterlight as your interpreter of choice. Neither is a good fit for Glimmr, however. The current version of Zoom (126.96.36.199) has a few bugs that impact heavily on Glimmr games, while Spatterlight is too old to have taken advantage of recent advances in speed (or bugfixes). Please consider downloading Gargoyle instead. (Gargoyle is also recommended for Linux and Windows users, though the latter have the option of Windows Glulxe/Windows Git.)