I’m using Emily Short’s “Menus” and “Basic Screen Effects.” The player can navigate the menus by using keystrokes. For instance, pushing ENTER causes the selected item to activate, while pushing the UP arrow changes which item is selected. She’s already mapped several keys with functions:
78 move down rule
110 move down rule
80 move up rule
112 move up rule
81 quit rule
113 quit rule
13 select rule
32 select rule
130 move down rule
129 move up rule
27 quit rule
I’d like to add the ESC key to this list as a quit rule. I can’t figure out what number ESC is associated with, though. Does anyone know how to figure this out?
What I’ve found so far: these numbers are relayed through “Basic Screen Effects” to use the function “GetKey()”. I cannot find any other reference to “GetKey(),” though. Not in the documentation nor in the standard rules.
Just tried it on a released version, and still no luck. That’s strange, though. The other keys are matched up with the ASCII table, so why wouldn’t it recognize ESC? I’ve tried using my ESC key with other programs, it works fine with them. Maybe another extension is interfering? I’ll look into it.
On a similar note, I want to have a menu pop up every time the player presses ESC. Is there a way to do this in inform? Specifically, is there a way to recognize when the player pushes ESC?
It’s possible, but complicated. Basically, you’d need to reimplement the basic input model (type a string and then register it using the return key) using the single-keypress model (each key registers as it’s pressed). Jon Ingold’s Interactive Parsing does this. Currently it looks like the ESC registers as a space, but you ought to be able to change that. I’m not sure that it would be worth it if you didn’t want Interactive Parsing’s other features, though.
Interactive Parsing looks promising. I’ve installed and fiddled with the code, but unfortunately, the relevant bits are written in Inform 6 and not Inform 7. Specifically:
I think you’ll probably have to do more than just fire the menu activation rules. You’ll also need to suspend or cancel the main game input, as well as restart it when you’re done with the menu. Depending on how the extension’s code is set up, this may be easy or it may be hard, and you may or may not have to write in I6 as well as I7.
Thanks for the suggestion, Emacs, but for some reason it’s giving a buggy response. The main menu doesn’t come up, but instead I get some nonsense text about a door. My feeling is that it’s not worth the effort. The player can still type “Menu” or I can even insert a hyperlink to bring up the menu screen. There are definitely options. Thanks, anyway!