Parser doc bug with lists?

I copied the code given in the documentation 21.2:
"Similarly,

let L be {"apple", "pear", "loganberry"};

makes L a list of texts;"

I also used a similar list-creating statement from documentation 21.3

let L1 be {2, 3, 5, 7, 11}; 

The parser returned a “can’t find a verb” error for both of them.
(Of course I copied only the code portion, not the doc portion.)
This is all the code I compile. Am I leaving something out or is this a bug in the doc or parser?

“Let” phrases can only be used in context, so it needs to be inside a rule or a phrase definition. For example:

When play begins:
    let L1 be {2, 3, 5, 7, 11};
    [do something with the list here]

In general, if the line starts with a lower case letter and ends with a semicolon in the documentation it’s a hint that that it’s a phrase that needs context, if that’s not already explicitly mentioned.

Let phrases create temporary variables that can only be used within the context. If you want a global list, the syntax is also described in chapter 21.2:

The list of prohibited items is a list of objects that varies.
The list of prohibited items is {the firework, the stink bomb}.
3 Likes

“Let” statements create what are basically local variables - they can only exist within a rule or “to say” statement or things like that. Outside of those contexts, you’ll need to create a global variable - which is easy enough:

L is a list of texts that varies.
L is {"apple", "pear", "loganberry"}.

I am totally confused. I have used this following structure many times, but cannot find the error here:

Pelts are scenery in cottage interior.
The beaver pelt, weasel pelt, mink pelt, coyote pelt, raccoon pelt, wolf pelt, and an unknown pelt are in cottage interior.

Description of pelts is "[description of trapper] [description of pelt sequence]".
Description of trapper is "[first time][printed name of grounds keeper in sentence case] was an ardent trapper.[only]".
Description of pelt sequence is "You see a [one of]beaver [or]mink [or] weasel [or]coyote [or] raccoon [or]wolf [or]er...ah...some other unknown kind of[stopping]pelt on the wall, among others.".
	
Instead of examining a pelt:
	if noun is: 
	-- beaver: say "It'll make a great hat.";
	-- mink: say "Now that is a valuable find!";
	-- otherwise:
		say "Usual fur, not particularly valuable.";

test peltz with "gonear cottage interior/ x pelts/ x beaver pelt/ x pelts/ x mink".

After the description of the cottage, I get exactly what I want when examining the beaver pelt, but I get the default description when examining the mink pelt… I changed the order of the two, and no difference.

x mink (or x mink pelt; I get the same default response)
You see nothing special about the mink pelt.

I’ve gone cross-eyed looking for typos.

It looks like you haven’t created pelts as a kind. So Inform doesn’t know to handle them collectively, and it is interpreting “Instead of examining a pelt” as “Instead of examining the beaver pelt”, since that happens to be the first created object with “pelt” in its name.

The problem here is that as far as Inform is concerned all your pelts are individually named generic things that happen to have ‘pelt’ as part of their name and are not members of a ‘pelt’ kind.

This means that when you write instead of examining a pelt Inform looks for the first thing it can find that whose name matches the word ‘pelt’- in this case the beaver pelt- and then stops looking. So when you type ’ x beaver pelt’ everything is OK, because it finds the matching beaver pelt- but when you type ‘x mink’ it again finds the beaver pelt, notes that it doesn’t match what you referred to (the mink pelt), and rejects the comparison (and therefore the whole Instead... rule)

To get this to work, you’d need to write something like:

A pelt is a kind of thing.
The beaver pelt, weasel pelt, mink pelt, coyote pelt, raccoon pelt, wolf pelt, and an unknown pelt are pelts in cottage interior.

Now when evaluating Instead of examining a pelt Inform will look for any member of the pelt kind, rather than the first thing it can find whose name matches.

EDIT: ninja’d!

EDIT2: Note that this however creates a new problem, because having created a pelt kind, now when you type ‘x pelts’ Inform knows that ‘pelts’ is the plural of ‘pelt’ and, assuming that you want to examine every pelt in the room, rejects this with You can't use multiple objects with that verb.

One (admittedly inelegant) way around this is rename your scenery as, say, ‘skins’ (you can still refer to ‘pelts’ in the room description) then capture any reference to examining ‘pelts’ plural when the player is in the cottage and redirect it to examining the skins:

After reading a command:
	If (the player's command matches "x pelts" or the player's command matches "examine pelts") and the location is the cottage:
		replace the player's command with "examine skins";

EDIT3: The neater solution is to call your kind ‘skin’, keeping your scenery as ‘pelts’. Then Inform will still interpret Instead of examining a skin as referring to any member of your skin kind, but ‘examine pelts’ will be directed at the scenery.

2 Likes

Wow! Thanks for this help. It is so convoluted it’s like learning an alien language. How was that ever figured out by anyone?
I’ll give that try.

Notably this doesn’t catch LOOK AT PELTS or X THE PELTS or Z. X PELTS or any of the myriad other ways to trigger the examining action. I strenuously discourage any attempts to re-implement the whole parser in “after reading a command” rules like this.

2 Likes

I was able to get the examine pelts to work without too much skins, but since the pelts are objects (that can be taken etc). this works.

A pelt is a kind of thing.
The beaver pelt, weasel pelt, mink pelt, coyote pelt, raccoon pelt, wolf pelt, and an unknown pelt are pelts in cottage interior.

Description of skins is "[description of trapper] [description of skin sequence]".
Description of trapper is "[first time][printed name of grounds keeper in sentence case] was an ardent trapper.[only]".
Description of skin sequence is "You see a [one of]beaver [or]mink [or] weasel [or]coyote [or] raccoon [or]wolf [or]er...ah...some other unknown kind of[stopping]pelt on the wall, among others.".
	
After reading a command:
	If (the player's command matches "x pelts" or the player's command matches "examine pelts") and the location is the cottage interior:
		say "[description of skins]";
		stop the action;

Instead of examining a pelt:
	if noun is: 
	-- beaver: say "It'll make a great hat.";
	-- mink: say "Now that is a valuable find!";
	-- raccoon: say "That'll make a great hat!";
	-- wolf: say "You might be able to sell that to a shaman.";
	-- unknown: say "You've never seen this kind of fur before. It is exceedingly strange.";
	-- otherwise:
		say "Usual fur, not particularly valuable.";

The only problem is that since I have a large list of pelt objects, the entire list is printed out in the look command, when I really want it to say some pelts, or similar.
I need to suppress the listing somehow.

About 12 pages of documentation say that this should work:

A pelt is a kind of thing.
The beaver pelt, weasel pelt, mink pelt, coyote pelt, raccoon pelt, wolf pelt, and an unknown pelt are pelts in cottage interior.

Before listing contents:
	omit contents in listing;
	group pelts together as "pelts";
	say "a bunch of pelts on the wall";

There is very little leeway about ‘omit contents in listing’. However, the individual pelts are listed anyway AND the number of pelts. At the bottom of the room description is:

You can also see a bunch of pelts on the wallseven pelts (a beaver pelt, weasel pelt, mink pelt, coyote pelt, raccoon pelt, wolf pelt, and an unknown pelt), a round table, three wooden chairs, a cot, and a work table here 

Another bug in listing rules?

Seriously, please don’t try to implement your own parser in “after reading a command” rules. It’s not worth it.

Just remove the plural “pelts” from the parser and make a new object to examine.

The plural of pelt is asdfasdf.
The plural-pelts are scenery in the Cabin.
The printed name is "pelts".
Understand "pelts" as the plural-pelts.

This is still a bit of a hack, to work around what I consider to be a bug in I7 (automatically recognizing plural names of kinds but not singular names). But it’s much less of a hack than writing your own mini-parser.

1 Like

“Listing contents” is the activity that prints the contents of an object (a container or supporter). Right now, your rule says, when the game is going to list the contents of a container, do not list those contents, group pelts together when you list them, and say “a bunch of pelts on the wall”. This means the contents of any container will print as “a bunch of pelts of the wall” instead of what’s actually in it.

Is there a reason not to simply make the pelts “scenery” (which means they’re not listed in room descriptions)? If you use the solution from my previous post, you can then make the plural-pelts not scenery, and put your description in there.

1 Like

The pelts are objects that can be Taken. It also can’t find scenery items because they don’t get listed–they are grouped as pelts, or a bunch of pelts on the wall. I am following ‘omit contents from listing’ as applied for the room descriptions (Section 18.10) but it doesn’t work as stated.

I would very much like to keep this as simple as possible, and not rewrite the parser, but I can’t get anything else to work.Everything about ‘x beaver pelt’ and ‘take mink’ works fine now. The only (I think unrelated problem) is that since the pelts are objects, they list individually in the room description, despite the grouping command. Omit contents from listing is suppose to stop that, but it doesn’t. I don’t know why, and I haven’t figure out some way to suppress it, despite the docs saying that’s all I need. Frustrating!

P.S. I hadn’t seen your plurals suggestion before I posted.

As Daniel says, that’s not right - “omit contents in listing” only applies to objects with contents, i.e. containers and supporters. So that doesn’t apply here.

If all you’re after is not having the individual pelts be mentioned by default in the room description, you can just mark them as undescribed, which should work in tandem with the scenery “pelts” object. NB you’ll probably want to move that off screen once the player’s taken all but one pelt off the wall, though.

Agreed. Player’s command-tweaking should be a desperate last resort for effects not available any other way…

Take a look at the grouping together activity in WI 18.14 for some ideas.

This is a rudimentary example:

Before listing contents: group pelts together.  Rule for grouping together pelts: say "various pelts".
1 Like

I simplified the problem by making a container so that I can do container things.
However, no matter what I did, I could not remove the parser override “After reading a command” to handle “x pelts” and still get it to work right. I would love to remove that since others are adamant about it being a bad idea. What should I do?

A pelt is a kind of thing.
A pelt rack is a container in cottage interior. "Many pelts hang from the wall."
A wolf pelt is a pelt.  Description of wolf pelt is "Perhaps you can sell it to a witch doctor.".
The beaver pelt, weasel pelt, mink pelt, coyote pelt, raccoon pelt, wolf pelt, and an unknown pelt are pelts in the pelt rack. 
	
Description of trapper is "[first time][printed name of grounds keeper in sentence case] was an ardent trapper.[only]".
	
After reading a command:
	If (the player's command matches "x pelts" or the player's command matches "examine pelts") and the location is the cottage interior:
		say "[description of trapper] You can see ";
		list the contents of pelt rack, as a sentence, and including all contents;
		stop the action;

Instead of examining a pelt:
	if noun is: 
	-- beaver: say "It'll make a great hat."; 
	-- mink: say "Now that is a valuable find!";
	-- raccoon: say "That'll make a great hat!";
	-- wolf: say "You might be able to sell that to a shaman.";
	-- unknown: say "You've never seen this kind of fur before. It is exceedingly strange and smells funny.";
	-- otherwise:
		say "Usual fur, not particularly valuable.";

As an aside, why is the list contents phrase redundant:

list the contents of pelt rack, as a sentence, and including all contents;
Why list the contents and say to include all contents?

I would think that

Understand "pelts" as pelt rack

would work to satisfy ‘x pelts’ but I get the default error response.
Perhaps if could make “pelts” be recognized as a singular pelt rack, then
‘x pelts’ would examine the pelt rack instead.
Any suggestions?

You could call the “pelt” kind something else, say animal_pelt. Then the plural “pelts” won’t be automatically generated by Inform. (In the player’s command, “pelts” should then be recognized as the pelts object, and “pelt” as referring to an unspecified animal_pelt, since they all have “pelt” as part of their name. Of course, you’ll have to make sure to use animal_pelt for the kind, rather than just pelt, everywhere in your code. I haven’t tested this btw.)