Initial description of something in a container.

I’m sure this has been asked before, but hopefully there’s a quick answer.

Is there a way to make the initial description of something appear when it is revealed in a container?

[code]
“Potty Mouth”

The bathroom is a room.

The toilet is a closed openable container in the bathroom. “[toilet status].”. The description is “[toilet status].”. It is fixed in place. Understand “seat/lid/bowl” as the toilet.

To say toilet status:
say “The toilet lid is [if the toilet is open]up[otherwise]down[end if]”

A toothbrush is in the toilet. “The end of a toothbrush is sticking out of the toilet drain. Thankfully, there’s no water in the toilet.”[/code]

Good question! I’d like to know the answer. And for supporters as well as containers. You’ll need to modify some of the Standard Rules – and this is complicated by a couple of factors. Mainly, the rules in question are set up to build a list. If your player puts five more things into the toilet, your game is going to have to be able to construct an appropriate list … yet your toothbrush will need to be mentioned before the list, and the list will need to start, “Also in [the item] you can see…”

I think this is a worthwhile enhancement to tuck away in an Extension. Maybe someone more experienced than I with the inner workings of the Standard Rules will be motivated to tackle it.

–JA

Maybe the most practical solution in this case would be to put the text in an “after opening the toilet for the first time” rule.

I’m bumping this topic because now I have a supporter with the same problem. In this case “for the first time” isn’t going to work because it’s not an issue of opening and closing.

I’m considering lying about the object being on the supporter, and having it actually just be in the location. I think I’ve noticed others doing the same thing.

Creating a special report rule for the toilet seems to work up to a point:

[code]“Potty Mouth”

The bathroom is a room.

The toilet is a closed openable container in the bathroom. “[toilet status].”. The description is “[toilet status].”. It is fixed in place. Understand “seat/lid/bowl” as the toilet. The toilet can be viewed or unviewed.

To say toilet status:
say “The toilet lid is [if the toilet is open]up[otherwise]down[end if]”

A toothbrush is in the toilet. “The end of a toothbrush is sticking out of the toilet drain. Thankfully, there’s no water in the toilet.”

A rubber ducky is in the toilet. “There’s a rubber ducky in the toilet, too.”

Report an actor opening the toilet (this is the first description of the toilet rule):
if the toilet is unviewed:
repeat with item running through every thing in the toilet:
say "[initial appearance of item] ";
now the toilet is viewed;
rule succeeds;
otherwise:
continue the action.[/code]

And if I’m not mistaken, it’d be pretty easy to generalize this to every container/supporter, or to every container/supporter that has a certain flag set (though if you did that you might have to manually list this rule before the reveal any newly visible interior rule, which I didn’t have to do here).

However, this rule is bugged; if the toilet contains an item that isn’t given an initial appearance, then it’ll produce a run-time error. You need a way to check whether the item has the initial appearance property, and I don’t know how to do that. Hopefully someone does.

All things have the initial appearance property, so in nearly all situations you’d only need to check whether that property has anything in it:

unless the initial appearance of the item is "":

If you wanted to have non-things (say, a direction) in the toilet, you’d need to first check whether it provided the property at all:

if the item provides the property initial appearance:

–Erik

Looks like the initial appearance property is used only in the “use initial appearance in room descriptions rule”. Which only runs during LOOK.

The Opening actions has the “reveal any newly visible interior” rule which sounds promising. It does this. Report an actor opening (this is the reveal any newly visible interior rule): if the actor is the player and the noun is an opaque container and the first thing held by the noun is not nothing and the noun does not enclose the actor, stop the action with library message opening action number 4 for the noun.

And that message is4: print "You open ", (the) x1, ", revealing "; if (WriteListFrom(child(x1), ENGLISH_BIT+TERSE_BIT+CONCEAL_BIT) == 0) "nothing."; ".";
…which just names the things in there (“toothbrush”), not print any description.

If you wanted initial appearance to fire on response to Examine instead, then, the examine containers rule is Carry out examining (this is the examine containers rule): if the noun is a container: if the noun is open or the noun is transparent: if something which is not scenery is in the noun: issue library message searching action number 7 for the noun; now examine text printed is true; otherwise if examine text printed is false: issue library message searching action number 6 for the noun; now examine text printed is true;

Which message #7 is 7: print "In ", (the) x1, " "; WriteListFrom(child(x1), ENGLISH_BIT+TERSE_BIT+CONCEAL_BIT+ISARE_BIT); ".";

which again only prints names.

I don’t know on which command you’re wanting initial appearance to appear, but there’s a starting point.

Ideally, I’d like the initial appearance to fire both when opening a container and when printing the room description when the item is visibly supported or contained in the location.

Is there an accessible property that can be used to mimic the initial appearance behavior (such as “touched” or “moved”)?

Hm. Is this new in 6E? When I ran my code in 5Z, adding “A cardboard tube is in the toilet,” I got (after “open lid”)

UPDATE: But “item provides the property” was exactly what I was looking for, thank you. I changed it to:

Report an actor opening the toilet (this is the first description of the toilet rule): if the toilet is unviewed: repeat with item running through every thing in the toilet: if item provides the property initial appearance: say "[initial appearance of item] "; otherwise: say "[An item] is in the toilet."; now the toilet is viewed; rule succeeds; otherwise: continue the action.

and it works even when an undescribed item is in the toilet. Well, the output is ugly, but that’s more of a writing problem than a programming one.

I think I have the supporter problem solvedish. You only automatically get the contents of scenery supporters anyway, thanks to the “describe what’s on scenery supporters in room descriptions rule,” which the documentation describes as controversial and which might not even be in 6E – I can’t remember. Anyway, the way the rule was written, I seemingly had to drop the code into it, and use the resulting rule instead of the preexisting rule. The result is not pretty; someone else may be able to do better.

Big wodge of code below the spoiler tag; it’s in 5Z, again.

[spoiler][code]“Potty Mouth”

The bathroom is a room.

The toilet is a closed openable container in the bathroom. “[toilet status].”. The description is “[toilet status].”. It is fixed in place. Understand “seat/lid/bowl” as the toilet.

A container can be viewed or unviewed. A container is usually unviewed. A supporter can be viewed or unviewed. A supporter is usually unviewed.

To say toilet status:
say “The toilet lid is [if the toilet is open]up[otherwise]down[end if]”

A toothbrush is in the toilet. “The end of a toothbrush is sticking out of the toilet drain. Thankfully, there’s no water in the toilet.”

A rubber ducky is in the toilet. “There’s a rubber ducky in the toilet, too.”

A cardboard tube is in the toilet.

Report an actor opening a container:
if the toilet is unviewed:
repeat with item running through every thing in the noun:
if item provides the property initial appearance:
say "[initial appearance of item] ";
otherwise:
say “[An item] is in [the noun].”;
now the noun is viewed;
rule succeeds;
otherwise:
continue the action.

The kitchen is west of the bathroom. A counter is in the kitchen. The counter is scenery. Some shards are on the counter. “Someone must have been clumsy or angry, because the shards of a broken bowl are scattered over the counter.” A glass is on the counter.

For printing a locale paragraph about a thing (called the item)
(this is the complex describe what’s on scenery supporters in room descriptions rule):
if the item is not undescribed and the item is scenery and the item does not enclose the player:
set pronouns from the item;
if a locale-supportable thing is on the item:
[here’s the start of the new stuff]
if the item is unviewed:
repeat with possibility running through things on the item:
if possibility is not mentioned:
if the possibility provides the property initial appearance:
say “[initial appearance of possibility]”;
say paragraph break;
otherwise:
say “[A possibility] is on [the item].”;
now the item is viewed;
[what’s below this is the standard rule again]
otherwise:
repeat with possibility running through things on the item:
now the possibility is marked for listing;
if the possibility is mentioned:
now the possibility is not marked for listing;
increase the locale paragraph count by 1;
say "On [the item] ";
list the contents of the item, as a sentence, including contents,
giving brief inventory information, tersely, not listing
concealed items, prefacing with is/are, listing marked items only;
say “.[paragraph break]”;
continue the activity.

The describe what’s on scenery supporters in room descriptions rule is not listed in any rulebook.

test me with “open lid/close lid/open lid/w/ look”.[/code][/spoiler]

BTW, when you open a viewed container, the “report an actor opening” rule falls through to the “repeat any newly visible interior” rule that Ron mentioned. It was because that rule was firing that I did it as a “report an actor opening” rule.

I haven’t been able to figure out how to do this when walking into a room with a transparent or open container.

I don’t think it’s new, but maybe there was a bug in 5Z71 that kept it from working properly. It certainly works in 6E.

Yes, that’s new (as of 6E59). Noted in the changelog:

“Previously, certain core Inform properties had the anomalous behaviour that if they were not explicitly defined then they could be read but not written…”

Ah, that explains why I’d never run into it before–I do that kind of thing all the time, but probably hadn’t tried it with any of the properties that were problematic.

–Erik

Good to know. I expect that means my code will need a tweak for 6E, to check whether the initial description is “” rather than whether it’s provided.

This should be error-free in both 5Z and 6E:

if the item provides the property initial appearance: unless the initial appearance of the item is "":

The first line will prevent 5Z from ever reaching the second (error-throwing) line.

–Erik