My game is going to have a few text walls in it, and I’d hate for someone to accidentally skip a crucial part of the dialog. If there was a way to wait for a specific key to be pressed instead of ‘any key’, I’d be very happy. Accidentally skipping a bit of dialog or exposition in a game that is clearing the screen may be the bane of my existence, so I’d like to go to extremes to avoid that.
I suspect this is an I6 sort of thing, so I’ve come to the forum for help. If there is a simple way to do this with Inform7 code, I’m not aware of it.
Thanks in advance to the old code knight that fixes my issue.
I definitely think you’re onto something. I’ll dig around and try to find the rest of that functionality.
Another odd thing I noticed as I was using the space key method, is that whenever I do press space to continue, I hear a sound play as if I pressed an invalid key.
Any ideas?
EDIT:
After searching around, I found this thread.
It seems that there is some way to do what I want using this hidden feature, but I’m not sure how.
The last reply on the thread is right on the money, but I’m not sure how to convert that to something that will wait until that key is pressed.
I’m going to mess around with it and see if I can come up with something.
Here’s what I’ve got, using most of Erik’s code from the other thread. It does exactly what I want, mostly.
[code]
Keychar is a number variable. [setting up the parser to identify specific key presses during transitions]
Keypress is an indexed text variable.
To get char input:
now keychar is the chosen letter;
now keypress is keychar resolved to an indexed text.
To decide which indexed text is (N - a number) resolved to an/-- indexed text:
if (N > 31 and N < 127) or (N > 160 and N < 384):[i.e., we have received printable input]
decide on “[char-code (N)]”;
otherwise:
decide on “”.
To say char-code (N - a number):
(- print (char) {N}; -)[/code]
Then, put this bit wherever you want the wait to occur:
while keypress is not "c":
get char input;
I’ll still need to figure out how to clear the parser between each press though.
It’s not being printed. I’m talking about the input box where the player types. Since no part of this command involves the enter key, that box is not being cleared.
I don’t like waiting for specific keys, unless it’s Space. I think you should wait for any key other than navigation keys such as Up/Down and PageUp/Down. This is some code I’m working on now:
[ Wait for a safe non navigating key. The user might press Down/PgDn or use the mouse scroll wheel when reading a menu page, so we will stop those key codes from returning to the menu. ]
To wait for any non navigating key:
while 1 is 1:
let key be the chosen letter;
[ Exclude Up/Down/PgUp/PgDn and ? which Gargoyle+Bocfel returns for unknown keys such as PgDn/Mouse scroll. Both Z-Machine and Glulx key codes are handled ]
if key is 63 or key is 129 or key is 130:
next;
if key < 0:
if key is -8 or key is -6:
stop;
next;
stop;
If you use the numbers it will be faster than converting to text with indexed text.
(It’s not perfect - other interpreters return strange keycodes for PgUp/Dn and mouse scrolling which I need to add.)
I’m using the Glulxe interpreter. If I have to, I’ll just allow the junk keys. I really don’t want to let space advance the text, since in my experience the key you’re most likely to press by accident is the space bar.
I understand your concern, but I think most IFers are more competent at their keyboards than that. Just saying, it’s never happened to me when I play. I could be in the minority, I guess. Best of luck with the game!