Forcing plural spellings

Let’s say I have a “tooth” object but then my player finds a second tooth. Is there an extension or something that lets me force the plural spelling of teeth?

If you’re defining teeth as a kind of thing, you can write this:

A tooth is a kind of thing. The plural of tooth is teeth.

and then the game will automatically refer to more than one tooth as “teeth.” You need to do this if you want to be able to refer to “teeth” in your source code anyway (well, Inform sometimes guesses plural forms, but I don’t know if it does that one).

You might also want to look at the printed plural name property (section 3.27 of the documentation) and maybe the printing the plural name activity (17.11), though that seems high-powered for what you want to do.

You guys are awesome. Had to write a special thing to test my behavior with my random item generator, but it works perfectly with singular and multiple forms.

OK back on my tooth question. Let’s say I have defined “teeth” as the plural of tooth and defined multiple tooth objects.

I can now create multiple teeth and pick them up and examine them.

But let’s say my player is holding say, 5 teeth. Is there a way to reference individual ones? I once played a MUD where this was done by say “wear 2.ring on 1.finger”. I’m not saying I want that particular usage, but you get the idea what I am asking.

Grrr. Beyond frustrating.

If I have the extension “Player Experience Upgrade” which includes the extension “Numbered Disambiguation Choices” then I have multiple items of the same type but DIFFERENT NAMES (in my case, several different TYPES of fossils that happen to be the same kind of things but named differently) and the player types “X FOSSIL” the Disambiguation extension pops up listing the exact different fossils you can examine.

But if I have four fossils named the SAME THING (such as four animal bones or four teeth) and I “X FOSSIL” or “X BONE” or “X TOOTH” I cannot individually examine the individual bones.

I didn’t want to define each fossil separately, that might become a pain to do. I like things like

A fossilized animal bone is a kind of fossil. There are 10 fossilized animal bones.

Frustrating!

So, hm. You want a bunch of objects that are listed as identical, but you also want the player to be able to distinguish between them? This seems like unfortunate design even if you could get it to work, unless I’m missing something important here. Assuming that this worked as you wanted it to, what would a transcript of the ideal behaviour look like?

The fossils have attributes, and I wanted the player to do specific tasks to the individual items. Then their description changes based on whether the tasks have been performed or not. I may end up adding additional clarifications, like the brown fossil or the cracked fossil, then just make one of each item instead.

Does it matter which one? If not, you could just use the phrase “a random tooth held by the player”. Like so.

Every turn when the turn count is divisible by ten: let the chosen tooth be a random tooth held by the player; if the chosen tooth is not nothing begin; say "You trip over and stumble, dropping one of your teeth in the process."; move the chosen tooth to the holder of the player; end if.

Hope this helps.

Can you be more specific about what you’re doing that isn’t working? This seems to work as I intend it to:

[code]Dentist’s Office is a room.
A tooth is a kind of thing. The plural of tooth is teeth.
A tooth can be molar, cuspid, canine, or bicuspid (this is its toothiness property). Understand the toothiness property as describing a tooth.
A tooth can be cracked or uncracked. A tooth is usually uncracked. Understand the cracked property as referring to a tooth. Understand the uncracked property as referring to a tooth.
Rule for printing the name of a tooth: say “[if cracked]cracked [end if][toothiness of the item described]”.

Four molar teeth are in Dentist’s Office.
When play begins:
now a random molar tooth is cuspid;
now a random molar tooth is canine;
now a random molar tooth is bicuspid.

Instead of attacking an uncracked tooth:
say “Crack!”;
now the noun is cracked.

Instead of attacking a cracked tooth:
say “It’s already cracked.”[/code]

OK here’s the code that’s not working:

[spoiler][code]A fossil is a kind of thing. A fossil can be clean or unclean. A fossil is usually unclean.

A tooth is a kind of fossil. The plural of tooth is teeth.

The mammoth tooth are a kind of tooth. Understand “fossil”, “fossils”, “artifact”, “rocks”, “specimen”, “tooth” as the mammoth tooth. There are 10 mammoth teeth. Mammoth teeth are ambiguously plural. The description of the mammoth tooth is “Seeming to be rocks to anyone else, these specimens, weighing about a pound each, are fossilized teeth from a mammoth. [if the noun is unclean][The noun] is covered in dirt and dust[else]You can make out every detail on [the noun][end if].”

An ammonite is a kind of fossil. There are 10 ammonites. The description of the ammonite is “Dating from the cretaceous period, this fossilized shelfish seems quite out of place in the deserts of Texas. [if the noun is unclean][The noun] is covered in dirt and dust[else]You can make out every detail on [the noun][end if].” Understand “fossil”, “fossils”, “artifact”, “rocks”, “specimen” as an ammonite.

A fossilized animal bone is a kind of fossil. There are 10 fossilized animal bones. The description of the fossilized animal bone is “You’re not quite sure what animal this bone is from. It could have been from an ancient turtle, or even a pleistocene era alligator. [if the noun is unclean][The noun] is covered in dirt and dust[else]You can make out every detail on [the noun][end if].” Understand “fossil”, “fossils”, “artifact”, “rocks”, “specimen” as the fossilized animal bone.

A gastropod is a kind of fossil. There are 10 gastropods. The description of the gastropod is “Evidence that the sea once covered parts of the United States, you are thrilled to find fossilized sea creatures from millions of years ago. [if the noun is unclean][The noun] is covered in dirt and dust[else]You can make out every detail on [the noun][end if].” Understand “fossil”, “fossils”, “artifact”, “rocks”, “specimen” as the gastropod.

A room can be searched or unsearched. A room is usually unsearched.

understand the command “dig” as something new.

Understand “dig with [something]” as digging with. Digging with is an action applying to one thing. Understand “dig” as digging with.

Rule for supplying a missing noun when digging with:
if the trowel is held, now the noun is the trowel;
otherwise say “You don’t have a suitable tool for that.” instead.

Check digging with something:
say “Nothing happens.” instead.

Instead of digging with something that is not the trowel:
say “You can’t dig with that.”

Instead of digging with in the Indoors:
say “There’s no suitable soil to dig here.”

Instead of digging with in the Outdoors:
if the location is unsearched and a random chance of 4 in 5 succeeds:
let F be a random fossil;
move F to the location;
say “You find [a F].”;
now the location is searched;
otherwise if the location is searched:
say “You’ve already searched here.”;
otherwise if the location is unsearched:
say “Your search turns up nothing in particular.”;
now the location is searched.

Instead of digging with in the Outdoors:
if the location is searched:
say “You’ve already searched for fossils here.”

Understand the command “clean” as something new.

Understand “clean [something] with [something]” as cleaning it with. Cleaning it with is an action applying to two things. Understand “clean [something]” as cleaning it with.

Rule for supplying a missing noun when cleaning something with:
if the brush is held, now the second noun is the brush;
otherwise say “You don’t have a suitable tool for that.” instead.

Before cleaning something with something not carried:
say “(first taking [the second noun])[command clarification break]”;
silently try taking the second noun.
[/code][/spoiler]

Basically, in an outdoor room, the player can “dig” to reveal a fossil if they possess the trowel. If they possess the brush, they can “clean” the dirt off the fossil. However, if the player possesses more than one of the same type of fossil, the code is not distinguishing between cleaning say, between three different mammoth teeth.

I’m currently trying an alternate where I physically create multiple objects that differ in actual names, but I am not fond of it.

Seems to me that they only need to distinguish between functionally different fossils: if there are three dirty fossils that are otherwise identical, why would the player care which one they clean first? And if there is a difference, then let that difference be how the player can refer to them. (In this case, let the player call them “clean tooth” or “dirty tooth” – there’s an example in the recipe book about breaking pots that does basically this.)

It’s inelegant but it works, I guess. If I have numerous of the same type of “dirty” fossils, I can repeatedly clean them until I no longer have dirty fossils. I tried defining individual fossils and the random function would allow the player to get the same fossil repeatedly, so it would have required tweaking. It does have some weird behavior I am going to have to work out.

Oh, btw… my code had the following:

Rule for supplying a missing noun when cleaning something with:
	if the brush is held, now the second noun is the brush;
	otherwise say "You don't have a suitable tool for that." instead.[/code]

Which was supposed to catch if the player typed "clean fossil" instead of "clean fossil with brush". It doesn't work. No matter what combination or variation of this I try, it insists I type the second noun.

I ended up eliminating the rule and adding 

[code]Understand "clean [something]" as cleaning. Cleaning is an action applying to one thing.

Check cleaning something:
	if the brush is carried:
		try cleaning the noun with the brush;
	otherwise if the brush is not carried: 
		say "You don't have a suitable tool for that."

It now works. I really hate things in Inform that you write by the manual and they don’t work.

I wish there was a way to force it to ignore certain errors, like you can do in some other environments.

It should be a rule for supplying a missing second noun.

ETA: I’d recommend making this apply when the brush is visible, so you wind up with this:

Rule for supplying a missing second noun when cleaning something with: if the brush is visible, now the second noun is the brush; otherwise say "You don't have a suitable tool for that." instead.

As you have it, “clean bone with brush” will result in an implicit take of the brush, but “clean bone” won’t, which seems annoying.

Also you should probably change your implicit take rule to this:

Before cleaning something with something not carried: say "(first taking [the second noun])[command clarification break]"; silently try taking the second noun; if the second noun is not held, stop the action.

Otherwise you will be able to clean the fossil even if you haven’t been able to pick up the brush.

On the original question, I agree with tove about the breaking pots example – that’s what the lines like “Understand the cracked property as referring to a tooth. Understand the uncracked property as referring to a tooth.” were doing in my original code. You might want to write some code that prints “clean” in front of the name of a clean fossil, to help the player realize that “clean mammoth tooth” will be recognized, though that can be tricky (for instance, you don’t want that to happen when cleaning the tooth, or your report of the cleaning may be “You clean the clean mammoth tooth.”)

Another thing that might help is this:

Does the player mean cleaning something with: if the noun is clean: it is unlikely.

So the game selects dirty fossils to clean first.

Another thing I noticed in your code is that the line “let F be a random fossil” can select fossils you’ve already dug up. You want “let F be a random off-stage fossil,” although you’ll need to check that there still are some fossils off-stage first.

I already have logic checking to see if the fossil is clean or not before it tries to clean, and I already have code that attempts to pick up the brush if it’s in scope. Thanks for the tip about the random, though.

Thanks for pointing out about the random. That change really changes the behavior of my tests. By the way, does anyone know how much memory in the z-machine individual objects consume? Like I’m creating some 40 objects by creating 10 of each kind… how will that affect my game? Will there be much change if I create say, 20 of each kind instead?

Agh this is still problematic. If I have say, multiple fossils of the same name in my inventory and I clean one, then do an “x fossil”, it’s not listing the clean ones. It lists the dirty ones. Then if I type “clean fossil” and try to clean one of the ones thats still dirty, it triggers the logic of the already clean fossil.

Is there a way I can repeat code through all the items in the inventory that have the same names, so maybe I could clean all the bones at once?

Well, that’s what the “Does the player mean” rule is supposed to take care of. It doesn’t just check to see whether a fossil is already clean once you’ve specified it as something to clean; if the player types something ambiguous, this rule will try to find a dirty fossil for it to clean. So if the player has a dirty tooth and a clean tooth, and they type “clean fossil,” then the game will automatically select the dirty fossil as the one they’re cleaning.

Sorry if this is duplicating stuff you already have or telling you things you already know – since I’m just working with a bit of your code (and I can see why you don’t want to post everything), I just added in enough to make it compile as a stand-alone fragment, and I’m adding stuff to that.

Well, you could make the cleaning action apply to multiple things, by using a “things” token. (This is what is used in the Standard Rules for taking, which is why “take all” works.)

Understand "clean [things] with [something]" as cleaning it with. Cleaning it with is an action applying to two things. Understand "clean [things]" as cleaning it with.

Then “clean all teeth” will work. I don’t know if it’s possible to make “clean teeth” be understood as “clean all teeth,” but maybe making “clean all teeth” is good enough for you.

FWIW, here’s the current version of [EDIT: the] code – since I only have one outdoors room, I disabled the code that forbids you from digging more than once in a given room. Another change I made is that I had “specimen,” “artifact,” etc. understood as fossils instead of adding it to each kind of fossil – makes it easier to add new kinds.

[spoiler][code]Include Plurality by Emily Short.

The Outdoors is a room. The Indoors is a room. The indoors is inside from the outdoors. The player carries a trowel. The player carries a brush.

A fossil is a kind of thing. A fossil can be clean or unclean. A fossil is usually unclean. Understand “fossil”, “artifact”, “rocks”, “specimen”, “fossils”, “artifacts”, “specimens”, “rock” as a fossil.

A tooth is a kind of fossil. The plural of tooth is teeth.

The mammoth tooth are a kind of tooth. There are 10 mammoth teeth. Mammoth teeth are ambiguously plural. The description of the mammoth tooth is “Seeming to be rocks to anyone else, these specimens, weighing about a pound each, are fossilized teeth from a mammoth. [if the noun is unclean][The noun] is covered in dirt and dust[else]You can make out every detail on [the noun][end if].”

An ammonite is a kind of fossil. There are 10 ammonites. The description of the ammonite is “Dating from the cretaceous period, this fossilized shelfish seems quite out of place in the deserts of Texas. [if the noun is unclean][The noun] is covered in dirt and dust[else]You can make out every detail on [the noun][end if].”

A fossilized animal bone is a kind of fossil. There are 10 fossilized animal bones. The description of the fossilized animal bone is “You’re not quite sure what animal this bone is from. It could have been from an ancient turtle, or even a pleistocene era alligator. [if the noun is unclean][The noun] is covered in dirt and dust[else]You can make out every detail on [the noun][end if].”
A gastropod is a kind of fossil. There are 10 gastropods. The description of the gastropod is “Evidence that the sea once covered parts of the United States, you are thrilled to find fossilized sea creatures from millions of years ago. [if the noun is unclean][The noun] is covered in dirt and dust[else]You can make out every detail on [the noun][end if].”

A room can be searched or unsearched. A room is usually unsearched.

understand the command “dig” as something new.

Understand “dig with [something]” as digging with. Digging with is an action applying to one thing. Understand “dig” as digging with.

Rule for supplying a missing noun when digging with:
if the trowel is held, now the noun is the trowel;
otherwise say “You don’t have a suitable tool for that.” instead.

Check digging with something:
say “Nothing happens.” instead.

Instead of digging with something that is not the trowel:
say “You can’t dig with that.”

Instead of digging with in the Indoors:
say “There’s no suitable soil to dig here.”

Instead of digging with in the Outdoors:
if [the location is unsearched and] a random chance of 4 in 5 succeeds:
let F be a random off-stage fossil;
move F to the location;
say “You find [a F].”;
now the location is searched;
[otherwise if the location is searched:
say “You’ve already searched here.”;]
otherwise[ if the location is unsearched]:
say “Your search turns up nothing in particular.”;
now the location is searched.

Instead of digging with in the Outdoors:
if the location is searched:
say “You’ve already searched for fossils here.”

Understand the command “clean” as something new.

Understand “clean [things] with [something]” as cleaning it with. Cleaning it with is an action applying to two things. Understand “clean [things]” as cleaning it with.

Rule for supplying a missing second noun when cleaning something with:
if the brush is visible, now the second noun is the brush;
otherwise say “You don’t have a suitable tool for that.” instead.

Before cleaning something with something not carried:
say “(first taking [the second noun])[command clarification break]”;
silently try taking the second noun;
if the second noun is not held, stop the action.

Check cleaning it with:
if the noun is not a fossil or the second noun is not the brush:
say “That won’t work.” instead;
otherwise if the noun is clean:
say “That’s already clean.” instead.

Carry out cleaning:
now the noun is clean.

Report cleaning:
say “You clean [the noun].”

Does the player mean cleaning something with:
if the noun is clean:
it is unlikely.

test me with “dig/dig/dig/dig/dig/dig/clean all fossils”.[/code][/spoiler]

Thanks. Similarly, for testing purposes, I have a command that resets the current location to unsearched.