Real-time input

I know this is a long shot, but: Is there any way to interact with the command being entered while it is being entered? That is, for the story to respond before the player hits enter?

The answer is no, at least if what you want is to check the content of the command itself before enter is pressed. …However, it would be possible to fake it. Rather than use the basic “line input”, you could revamp Inform’s default input routines to use keystroke input instead. Keystroke input is the type of input used to handle “press any key to continue”, but instead of “continuing” when a key is pressed, you’d add it to the player’s command, print it to the command line, and then restart the input loop. When the player pressed return/enter, you’d stop the loop and tell Inform to process the command as normal. You could then do anything else you wanted to during each loop, such as check for a real-time event, match the developing command to a regular expression, etc. You could even disallow the letter “e”, for example, if you wanted the player to have to play like an Oulipian.

My Glulx Input Loops extension would make this process pretty easy–at least if you’re using Glulx. If you’re targeting z-code, though, you’d have to hack the I6 input loops yourself. There are other significant drawbacks:

  1. The player won’t be able to paste to the command line.
  2. You will need to program arrow key behavior yourself. This isn’t hard–I did it for the Glimmr Form Fields extension–but it would need to be done.
  3. Unless you use a grid window, the player won’t be able to delete previously typed characters (and again, you’ll need to create this functionality yourself).
  4. On a slow interpreter or slow device, the player may be able to type faster than the game can handle.

Chances are, you won’t think that the functionality you’re after is worth the compromises and implementation time. And you’re probably right!


I did something similar in the extension Command Prompt On Cue, which waits for the player to press space to continue reading, or if they start to type something it’ll display the command and accept the rest of the input normally. Even on my 1Ghz desktop, I’d lose the 2nd letter to typing speed more often than not.

With a lot of Glk work you should be able to do this. You can start a timer and when it goes off then call glk_cancel_line_event(). After that the buffer will be filled in with the partially complete command. After doing whatever you like, you could then call glk_request_line_event() specifying that you want to resume input using that same buffer. And you can reset the timer again if you want to keep checking what the player is typing.

This may however result in several partially completed input lines?

Yes, canceling a line event will insert a carriage return–probably very confusing for the player. If you used a grid window for input, you could probably get around the line break (by resetting the cursor), but the timer would probably not be a foolproof solution in any case.

On the other hand, maybe a timer is what the OP is looking for: I took “real-time” to mean that the input could be checked keystroke by keystroke. (I suppose that it’s also possible that the OP is just wondering whether a command can be interrupted by a real-time event. That is definitely possible with Glulx–there’s a thread from a few months ago that shows how to do this.)


I’ve designed an Glk update which will allow the game to suppress the carriage return (in buffer windows). I should have it posted this weekend, so that the Mac and Windows interpreters can implement it. (Already implemented in my Quixe sandbox.)

It still won’t be completely invisible to the player, though. He might see a hitch in the UI’s typing response, and it would probably reset the cursor position.

I did mean checking the input character-by-character, and no, that doesn’t sound worth it. Especially since I was looking for a particular command (rather than using it in a particular situation), so I’d have to implement it for the entire game.

I don’t know if this would suit your purposes at all, but some z-code games sometimes force you to input something – at a certain stage no matter what you type, it turns into the letters of the input the game wants. Probably the quickest way to see this in action is to go to Pick Up the Phone Booth and Aisle

and enter “undo” as your first command.

Obviously this isn’t exactly what you’re looking for, but would you be able to work it so it accepts the specific command normally, and then the next turn forces your input in this way? It seems like a similar sort of thing that’s actually been implemented.

I don’t actually know how to code this, though.

Great news–thanks for the new (and ongoing) Glk stuff!


I swear I’ve seen the code for this somewhere–was it covered in the DM4? Anyway, it’s possible that this technique might lead to a z-code solution to katz’s question: If you can intervene character-by-character in z-code input to change what’s written to the input buffer, it’s quite possible that you could also check the buffer character-by-character as she wants to do…


The fake-forced-entry trick is a lot easier than what the OP is asking for. “Basic Screen Effects” has an example, “The High Note.” It’s totally cheating: it prints a prompt character, but it hasn’t actually generated a true prompt. Then it waits for keypresses to advance printing the forced command to screen. IIRC, the way to do this in I6 is rather similar.

I don’t see a way around it for the purposes of the whole game without some pretty heavy-duty work, as Erik said.

Thanks, Emily–I was hoping this might be one of those rare situations where the z-machine was more flexible than glulx, but no dice!



Yeah. To be clear, I was trying to suggest the fake-forced-entry as a related trick that would require some redesign, but that was actually doable. So if Katz’s idea is that the command “feed cat alfalfa” gets replaced with “feed cat cheezburger” as you type, maybe you can’t do that, but you can do this:

O’course I don’t know if what she has in mind is at all conducive to this kind of solution.

Yeah, I’ve seen the fake-forced-entry trick (it was used in Blue Chairs, no?), but of course that’s something that you use on a specific turn, not through the whole game.

Second best option: After the command is entered, can I edit the input buffer so that what gets parsed and printed is what I want, as if that was what the player had entered?

IE: Player enters FEED CAT ALFALFA


Inform prints and parses FEED CAT CHEEZBURGER

That, at least, is both doable and easy:

After reading a command when the player's command matches "give cat alfalfa": change the text of the player's command to "give cat cheezburger"; say "I think you mean: GIVE CAT CHEEZBURGER. Yeah, let's go with that...";