Oops, there’s another place where I’m trying to get input in a loop, with the same bug.
To get an input:
(-VM_ReadKeyboard(buffer, parse);-)
while 1 is 1:
say "Type the name of the feat you want> [run paragraph on]";
get an input;
let q be the player's command;
say "Q is [q].";
It seems to get an input is extremely unreliable. Is there a better way to do that?
What do you mean by “interrupt other processes”? Questions hijacks the main input to put toward whatever purpose you like, and it uses the parser to allow you to restrict valid input to a certain class of entities. You can build your own input routine and parser if you like, but … why, when that’s (probably) not necessary?
If you really want to do this yourself, VM_ReadKeyboard is not the right point of entry. Take a look at the YesOrNo() routine in the I6 template (basically, the same routine that climbingstars included, with modification, in his/her post in this thread). Or you could use Glulx Input Loops to set up a line input loop with its own specific handling rules.
It captures nothing, parse–>0 returns nothing in printtext, as does buffer–>1, I’ve tried parse–>1. Where did the data go? How do I grab it and stuff it into playerinput?
You haven’t really explained what effect you’re trying to achieve, but here’s how to capture what I think you’re looking for using the Questions extension. (Sorry, I doubt you’re going to get any takers for helping you to reimplement the parser in I6. But I’ve been wrong before…)
[code]Include Questions by Michael Callaghan.
Bragging is an action applying to nothing. Understand “brag” as bragging.
Bombast Chamber is a room. “Here you may BRAG.”
Instead of bragging:
now current question is “”;
now current prompt is “Of what great feat do you wish to tell?[line break]>>”;
ask a closed question, in text mode;
Rule for printing a parser error when we are asking a question and the command parser error is the I beg your pardon error:
say “You decide not to speak.”;
deactivate text question mode.
A text question rule when the player is in the Bombast Chamber:
if the current answer matches the regular expression “^(I |My )”, case insensitively:
say “Plaudits resound!”;
exit;
otherwise:
say “Your story lacks verve. Try again.”[/code]
All I need to do it get input, and put it in a variable. I have the variable. I have input(I think). I just need to connect A to B. I can do all the parsing on my own, that is not the challenge. I just need one line of input. That’s it.
A first when play begins rule:
while 1 is 1 begin;
let k be 0;
while k is 0 begin;
let k be the chosen letter;
end while;
if k is 13 begin;
say “You pressed the Return Key!”;
otherwise if k is 31 or k is 32;
say “You pressed the Spacebar!”;
otherwise if k is 65 or k is 97;
say “You pressed the ‘A’ key!”;
otherwise if k is 66 or k is 98;
say “You pressed the ‘B’ key!”;
otherwise if k is 67 or k is 99;
say “You pressed the ‘C’ key!”;
otherwise if k is 68 or k is 100;
say “You pressed the ‘D’ key!”;
otherwise if k is 69 or k is 101;
say “You pressed the ‘E’ key!”;
otherwise if k is 70 or k is 102;
say “You pressed the ‘F’ key!”;
otherwise if k is 71 or k is 103;
say “You pressed the ‘G’ key!”;
otherwise if k is 72 or k is 104;
say “You pressed the ‘H’ key!”;
otherwise if k is 73 or k is 105;
say “You pressed the ‘I’ key!”;
otherwise if k is 74 or k is 106;
say “You pressed the ‘J’ key!”;
otherwise if k is 75 or k is 107;
say “You pressed the ‘K’ key!”;
otherwise if k is 76 or k is 108;
say “You pressed the ‘L’ key!”;
otherwise if k is 77 or k is 109;
say “You pressed the ‘M’ key!”;
otherwise if k is 78 or k is 110;
say “You pressed the ‘N’ key!”;
otherwise if k is 79 or k is 111;
say “You pressed the ‘O’ key!”;
otherwise if k is 80 or k is 112;
say “You pressed the ‘P’ key!”;
otherwise if k is 81 or k is 113;
say “You pressed the ‘Q’ key!”;
otherwise if k is 82 or k is 114;
say “You pressed the ‘R’ key!”;
otherwise if k is 83 or k is 115;
say “You pressed the ‘S’ key!”;
otherwise if k is 84 or k is 116;
say “You pressed the ‘T’ key!”;
otherwise if k is 85 or k is 117;
say “You pressed the ‘U’ key!”;
otherwise if k is 86 or k is 118;
say “You pressed the ‘V’ key!”;
otherwise if k is 87 or k is 119;
say “You pressed the ‘W’ key!”;
otherwise if k is 88 or k is 120;
say “You pressed the ‘X’ key!”;
otherwise if k is 89 or k is 121;
say “You pressed the ‘Y’ key!”;
otherwise if k is 90 or k is 122;
say “You pressed the ‘Z’ key!”;
otherwise;
say “You pressed something else!”;
end if;
end while.
The Testing Room is A Room.[/code][/spoiler]
The numbers are the ASCII values of the key pressed.