"That's not a verb I recognise" appearing when I don't want it to

Heya all,

After building a little clothing system (with some help from you guys) for a prototype personal game, just to get used to Inform 7, I decided to make a quick “get dressed” command that throws the player into a default work outfit.

But I wanted to give the player a choice between one article of clothing, because I’ve never asked for input like this before and I’m still not really sure how to ask the player a question other than getting their name.

Here’s what I created:

[Quickly put clothes on at the start of the game]
GetDressed is an action applying to nothing.
Understand "Get dressed" as GetDressed.
Report GetDressed:
	if the player is in Your Apartment:
		now Your Closet is open;
		if BDC shirt is visible:
			now the player is wearing the BDC shirt;
		if the Cotton Bra is visible:
			now the player is wearing the Cotton Bra;
		if the Cotton panties are visible:
			now the player is wearing the Cotton panties;
		say "Skirt or Shorts?";
		now the command prompt is "Skirt or Shorts >";
		
To decide whether getting dressed: 
	if the command prompt is "Skirt or Shorts >", yes; 
	no. 

After reading a command when getting dressed: 
	if the player's command matches "skirt":
		say "[paragraph break][player forename] chooses the skirt and puts it on."; 
		if the BDC Skirt is visible:
			now the player is wearing the BDC Skirt;
			now the command prompt is ">";
		otherwise:
			say "That doesn't appear to be a choice.";
			reject the player's command;
	if the player's command matches "shorts":
		say "[paragraph break][player forename] chooses the shorts and puts them on."; 
		if the BDC Shorts are visible:
			now the player is wearing the BDC Shorts;
			now the command prompt is ">"; 
		otherwise:
			say "That doesn't appear to be a choice.";
			reject the player's command.

This appears to work fine, putting either shorts or a skirt on the player, provided the player is in their apartment and so are the clothing articles, aside from one issue.

Every time the player types either shorts or skirt, I get this little error beneath my say output:

Kara chooses the shorts and puts them on.
That's not a verb I recognise.

I think because the game is assuming the player is trying to do something, when they’re supposed to be asking a question. So I figured I’m doing something wrong here and wondering if anyone can give me advice; either to better set up a binary or multiple choice for the player, or to stop that verb error message from popping up.

Many thanks!

1 Like

You need to explicitly reject the player's command in every case when asking a question like that, otherwise Inform will proceed to interpret the input as a command as usual.

2 Likes

Yeah. To elaborate, you’re inserting code inbetween the “gathering input” part of the turn and the “parsing the input” stage.

“After reading…” rules happen before the input is parsed. So you’ve created a hack where you watch for particular words, in particular circumstances (the prompt is the shorts or skirt question), and react by running some code. But after running that code, the command is continuing on to the parsing input stage because you didn’t “reject the player’s command”. At which point, Inform thinks the player has typed in the command “skirt”, and says “I don’t know that verb.”

In finesse land re: the logic of your code, note that the primary condition you’re checking is “Is the closet open?” So for instance… if the player’s already taken clothes out of the closet, but the player has since closed the closet, the GET DRESSED routine will fail because the closet isn’t open.

Secondly, the routine is definitely going to run if the closet is open!.. no matter what else is happening. So if the closet’s open, the player will try to put on any of those items you listed, and will put on any it can see. But it may see none, and put on none, or only put on one or two. It’s also going to ask “Skirt or shorts?” regardless of the status of the skirt or shorts. No matter where they are – visible, worn, lying on the floor in another room - it’s going to ask that question and then teleport the chosen item onto the player.

I may be back later with a refined version of what you’re attempting, or someone else might, but in the meantime, you can consider this a demonstration of examining the logic of an action you’re setting up to make sure that it makes sense regardless of circumstance, or at least not in only one specific circumstance.

-Wade

2 Likes

Thanks for the detailed breakdown!

The get dressed function is definitely unrefined and mostly for my own convenience; having to manually throw clothes onto my character any time I want to go outside or do anything takes longer than clicking a single hyperlink that basically macros the actions for me.

I’ll throw in some conditions to stop it from breaking if the clothes aren’t where expected. But because the command doesn’t check if the closet is open or not, it just forces the door open to make the clothes inside visible, I figured it was fine to throw it together this way, for now. Really, it was the verb not being recognised error issue that I was most concerned about, glad to see there’s a simple solution there.

I’m not sure if I should ask here or make a new post but I figure my question is quite similar to what is being done here. But I am curious what is generally the best way to go about getting user input while doing an action such as in this example? Is changing the command prompt and rejecting everything but the accepted answers the best way to go, or is there a way to do something more akin to if the player consents which tbh I don’t really understand how that works (I assume at the I6 level)? I’m especially curious if there are better ways to go about this in regards to continuing an action, such as how in this example the action is pretty much split in two between what is done when the player does the initial action, and then there is separate behavior handled by the After reading... rule; is there a way to easily get the user’s input, in this case if they want to wear the skirt or shorts, and then have the getdressed action be able to handle that during the same turn?

(If need be this can be split off into another topic and/or I can provide more information for my specific use case)

I think the hard, I7 programming paradigm answer is: Don’t try :slight_smile: (actually trying anyway considered after some context)

I7 wants to parse a full command every turn, and it wants to consider all of the world model that’s exposed to the player on that turn as it does this.

It’s really only got one built-in mechanism to make doing anything else easy, and that’s “If the player consents” – which makes it easy to ask a yes or no question, have irrelevant input culled, and then allow the author to react. This is why writing or negotiating with extensions to produce discrete choice menus in I7 is traditionally a chore at least. I’ve discussed this topic before a few times so I’ll just link to my most recent incidence of it as of me typing this: Recommendations for learning about menu based dialogue systems - #11 by severedhand

… So if you want to try presenting a ‘Skirt or shorts?’ type question anyway, there is no best practice, only what will work best in your context.

Doing it the way Sabine has done, by changing the command prompt and using ‘After reading a command’… has the huge advantage of allowing you to screen out the rest of the world model and unwanted commands by adding a few pieces of rejecting code to the routine. So if you have only a few incidences of this in your program, this could be a good way to go.

If you want to build a system, it’s probably not. Maybe then you could go to Hybrid Choices or similar extension, which would present a list of alternatives that you could construct. It’s most people’s go-to for presenting options, though I have this real bee in my bonnet about the world model being exposed and the turn loop continuing when I want to ask closed questions, so it has never vibed with me.

Another way, alluded to in my post that I linked to, and which I’m personally fond of ,is using the ‘hacky keypress’ method. (Btw, I just coined this term ‘hacky keypress’. It’s not really any more or less hacky than Sabine’s method.) Really, this is presenting a list of options and asking the player to choose one by pressing a number or letter key. Again, a titanic advantage of this method is that it cuts out all the world model and unwanted commands. The program literally stops and waits for a keypress, and you can send it straight back into the wait if it doesn’t get one you asked for. It also allows you to act on the response mid-turn, which Sabine’s method does not. It is easier to program than Hybrid Choices, and could be made into a system. But, you have to be happy with the game going to ‘taking a keypress’ mode for a moment. If for any reasons you want the player to always respond by typing a command and pressing ENTER, then you wouldn’t want to use the ‘hacky keypress’ method, and maybe Hybrid Choices would be more your style.

So to triage… I would try to avoid entering situation where you need to ask player a non yes or no question in the first place by programming in the parser. You know, in Sabine’s example (except that hers may be for a cheat/help command, but forget that for a moment) the player could just type ‘wear skirt’ to wear the skirt and ‘wear shorts’ to wear the shorts. If we allow ‘get dressed’, I’d prioritise whichever of the two items was available, and if both are, I’d cheat by always favouring one over the other for an in-character reason I’d present: “The shorts will be more practical for what I’m doing today.”

Next stage of triage is, exploit the ‘If the player consents’ mechanism if you can, because it’s built-in.

Next stage is, settle on a workaround or workarounds. Changing the prompt and using ‘After reading a command’, or using an extension that creates choices, or using the hacky keypress method, or doing something else I haven’t thought of right now.

-Wade

2 Likes

It’s possible to get a line of input outside the usual command-loop:

Lab is a room.

To decide what snippet is the/-- line input:
  (- getLine() -)

Include (-
[ getLine;
KeyboardPrimitive(buffer, parse);
return 100 + WordCount();
];
-).
how-high is initially "".
Inquisitive is a scene.
Inquisitive begins when the current action is jumping.
Inquisitive ends when the current action was jumping.
When inquisitive begins: say "how high? "; now how-high is "[line input]";
say "[how-high] high.";

…but notice how this has a scene ask for the line input. That’s 'cause if you ask for line input by this method during action processing, it won’t happen until after the action processing is finished.

So as weird a technique as it may seem to hijack the command loop to get a line of input by changing the command prompt and rejecting the player’s command, it’s a perfectly viable strategy and possibly the simpler one: it basically guarantees you can’t make the mistake of trying to ask for input in an action rule.

(The above was basically lifted from my Inquiry extension for multiple-choice or line-input questions.)

It ought to be possible, I think, to write one’s own line input routine by reading indvidual keypresses, and it must have occurred to me half a dozen times while writing Inquiry that that’s what I should do. And then half a dozen times over I thought about backspaces and cursor keys and the related display update issues and decided it wasn’t even close to worth it to try.

1 Like

Also, I should have probably talked up the Unified Glulx Input extension in this thread directly; I mention it in the topic I linked to. It lets you create new input contexts and rules. So you could create a ‘skirt or shorts’ context, or some more flexible systemic context for asking questions like that. The new modes operate within the normal Inform turn cycle (i.e. an input takes a turn).

-Wade

1 Like

Link to Unified Glulx Input for reference…

1 Like

@Zed and @severedhand, thank you both for the resources, I’ll have to check these out in greater detail. I did have one question about the I6 method using scenes. Does it not working during action processing mean during all of the before,carry out after etc rulebooks or just when the parser is trying to figure out what the player is trying to do? Either way the scene workaround actually seems like it may do what I need, but again I’ll need to take a closer look.

The example has the line “Inquisitive begins when the current action is jumping.” You might think this happens while the player in jumping. But, in fact, scene changes are processed at the end of each turn. (Right before the “every turn” rules.) So the entire jumping action will happen before the scene change rule fires.

2 Likes

here’s another reference: Emily Short’s rules flowchart which details the turn sequence and the action processing sequence within it.

3 Likes