Issue with Printing the name of...

I have encountered an issue with a “rule for printing the name” of a kind of thing I’ve created. By chopping my code down to the following, the issue disappears, so I can’t demonstrate anything, really. Nevertheless, by describing the symptoms, perhaps someone can help me search for the answer towards the right direction.

This is part of my code:

[code]A thing can be blood-stained or fresh.

A shard is a kind of thing.

Rule for printing the name of a shard:
if the shard is fresh, say “shard of glass”;
else say “blood-stained shard of glass”.
[
Rule for printing the name of a shard:
if the shard is blood-stained, say “blood-stained shard of glass”;
else say “shard of glass”.
]
[/code]
Then, a murder happens and the shard turns from fresh to blood-stained. Despite the fact that the change of property happens (I can see that with SHOWME), the above code still returns the printed name of a clean (fresh) shard. On the other hand, if I use the code in brackets instead (thus having “blood-stained” instead of “fresh” in the ‘if’ clause), the printing works as it should.

I suppose there is some other rule that overrides something, but I have no clue how to look for it. Any thoughts?

Many thanks!

“The shard” doesn’t necessarily refer to the shard you’re talking about, if there’s more than one. If I recall correctly it refers to the first shard declared in the source code. This is one of the weirdly unintuitive parts of Inform’s noun parsing.

Rule for printing the name of a shard (called the glass): if the glass is fresh, say "shard of glass"; else say "blood-stained shard of glass".

Or:

if the item described is fresh...

You can also have it be implicit which thing you’re talking about:

Rule for printing the name of a shard: say "[if not fresh]blood-stained [end if]shard of glass".

I think it means the same thing as “a shard,” so “If the shard is fresh” comes out true if any shard is fresh.

Oh, now I get it! I actually hadn’t realise that I have 4 shards in play -I checked my Index- which get created by the following series of rules:

[code]
Every glass shatters into a pile of broken glassware.
Every bottle shatters into a pile of broken glassware.
Every demijohn shatters into a pile of broken glassware.
Every jug shatters into a pile of broken glassware.

Every pile of broken glassware incorporates a shard.[/code]

(For the ‘shattering into’ relation discussion, see my older thread here.)

So, yes, I will go with:

Thank you guys!