How to get the input.

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?

The Questions extension is designed for stuff like this.

Interesting, but would not work well to actually interrupt other processes, since it just uses the normal parser.

How can I get VM_ReadKeyboard to behave properly?

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.

Giving it a shot!

How do I set an inform 7 variable from within inform 6 code? I try and it says I’m referring a constant. Is it possible?

It sure is! You have to put the inform 7 variable inside “(+ +)” tags.

See “25.18. Longer extracts of Inform 6 code” in the Inform 7 documentation.

Hope this helps.

Ok, I’m getting awful close now. How do I get parse(which is an array?) into a single variable nice and neat? I want all of the words.

To get an input: (- for (::) { PrintText( "Hi!" ); #Ifdef TARGET_ZCODE; if (location == nothing || parent(player) == nothing) read buffer parse; else read buffer parse DrawStatusLine; #Ifnot; ! TARGET_GLULX; KeyboardPrimitive(buffer, parse); #Endif; ! TARGET_ (+ playerinput +) =parse-->1; PrintText( parse-->0); PrintText(" - "); PrintText( buffer-->1); PrintText( "Bye!" ); break; } -)

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?

Apologies for bumping, but does anyone know enough inform6 to take a crack at this?

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]

This produces output like the following:

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.

This will do that very limited task:

[code]The player’s input is a snippet variable.

To get typed command as (S - a snippet): (-
KeyboardPrimitive(buffer, parse);
{S} = 100 + WordCount(); -)

After looking:
say “>>”;
get typed command as the player’s input;
say “You typed: [player’s input]”.

Test is a room.[/code]

You’ll need to convert the snippet to indexed text before you can do much of anything with it in I7.

It… works!

It does everything I want it to do. Thank you so very much.

Also, it seemed to work straight away without any odd conversions:

if playerinput in lower case matches the text title entry in lower case:

Worked great. Thank you again.

Fresh query.

KeyboardPrimitive(buffer, parse); works fine for a line, what would I use to grab the first key hit?

Something like this.

[code]Include (-

[ GetKey i;
i = VM_KeyChar();
return i;
];

-)[/code]

Hope this helps.

Hrm, I’m trying to get it into a variable. I tried this, which did not compile.

To get next key as (S - a snippet): (- {S} = VM_KeyChar(); -)

Fixed, thanks!

In that case you want something like this.

[spoiler][code]“Test”

Include Basic Screen Effects by Emily Short.

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.

Hope this helps.

Thank you kindly, good sir.