The noun the player typed?

How can I make the parser return the noun player typed rather than the object’s name? Say I have:

The tree's features are a backdrop. Understand "branch/branches/leaf/leaves/twig/twigs/bark/sap" as the tree's features.

And the player types:

Look at leaves.

I want it to say ‘You see nothing special about the leaves.’, and so on, without making all the individual objects.

Anyone know how can I achieve this? Thanks for reading.

Try this.

[code]Understand “examine branch/branches/leaf/leaves/twig/twigs/bark/sap”, “look branch/branches/leaf/leaves/twig/twigs/bark/sap” and “read branch/branches/leaf/leaves/twig/twigs/bark/sap” as a mistake (“You see nothing special about the [word number 2 in the player’s command].”).

Understand “look at branch/branches/leaf/leaves/twig/twigs/bark/sap” as a mistake (“You see nothing special about the [word number 3 in the player’s command].”).[/code]

Unfortunately Inform doesn’t allow the slash shorthand for the first word. However this works well.

Hope this helps.

That works great! Many thanks.

Trying to catch normal player commands as a mistake is generally a mistake. You wind up working twice as hard for a result which is half as good.

In this case, you have to be careful to catch every verb synonym (if you added more grammar for “examine”, you’d have to remember to fix each of these mistake declarations). You have to be careful about noun synonyms (this will miss “examine the leaf”, and if you happen to mention green leaves in the room description, the player might try “x green leaf”). And you have to be careful about other verbs (what if the player tries “take leaf” or “feel bark”?)

Then there’s the question of whether the player’s command is really up to printable standards. In Glulx, “X LEAF” will produce the output “You see nothing special about the LEAF,” because the command buffer retains the player’s capitalization. If you include a ten-letter synonym, you may wind up repeating the player’s truncation or misspelling beyond the ninth letter.)

If you really want to be pedantic, complain about the failure to set “it”…

Making two or three individual backdrops is, it winds up, the easy and good solution. (One for “leaves”, one for “branches”.) Or you can make one backdrop with a nice general message about “greenery”.

Zarf makes a good point. The annoying thing is the branches, leaves and even the trees aren’t actually mentioned in my game, but the player is in a forest, so I want them to able to type that kind of stuff. Maybe I’m being OTT with attention to detail, but that’s just me.

It seems to me that functionality would be worth adding in to I7 to allow better parser response. If you could type something like “the recognised noun in the player’s command”, for example. Is it possible an extension could handle this?

If that’s the situation, just give some generic response about the trees. Not as generic as “You see nothing special about…,” though, no one gives you any extra points for that even if it took a lot of work to get it. Something like:

“You never paid much attention in forestry class. These trees look like the kind with branches and leaves, but that’s about all you can say.”

would probably discourage the player from trying to do stuff with the individual trees if that’s what you wanted.

Veering towards game design forum territory here, but it alway amuses me that 90% (ish) of the things in Zork are ‘You see nothing special about…’ descriptions. I do think there’s an argument to be made for not describing every single thing, but again that’s just me. Matt W’s solution is what I was using originally anyway, so guess I’ll just go back to that.

It should be possible to set up a “snippet which refers to the noun” function in the I7 model. The thing is, most of the objections I made above still apply. You’ll wind up printing text like “You see nothing special about the THE LEAVES GREEN,” depending on the situation.

Surely you could force lower case? Not come across snippets before, I’ll take a look.

How would you do that? I’ve been desiring this for a while.

Yes, you can force lower case. Sometimes that will be wrong, too.

I do not have code on hand to do this snippet thing, precisely because I think the results are bad! I’m just saying that the parser model has enough information to keep track of it.

But the functionality is already firmly in place. Why force yourself to jump through hoops? Why not just create a separate scenery object for each of the nouns? That’s what scenery is for.

I have to agree this is a bad idea, also because it might be confusing to the player if it’s not clear what nouns are synonyms and what are independent objects. But if someone wants to shoot themselves in the foot, who am I to deny them a gun?

[code]The forest is a room. A small orange frog is in the forest. A small orange leaf is in the forest. A small green leaf is in the forest.

Instead of examining the orange leaf:
say "You see nothing special about the ";
if the player’s command includes “[orange leaf]”:
say matched text;
otherwise:
say “[orange leaf]”;
say “.”[/code]

Example output:

Haha, I’m just going to avoid this whole mess and make some scenery. Many thanks to all.

Thanks Juhana! I see that there’s more about this in 17.31, including a more or less explicit statement that snippets are useless outside a few set uses.

The particular bad ideas I have don’t seem well suited to this, but I’ll keep it in mind as an avenue for future tinkering.