Printing a non-default non-initial appearance

I’m sure this is an easy one, but I’m not finding the solution in Chapter 18. I have an object that is starting offstage (in a room called Limbo). When a certain scenery container is searched, the code causes the object to be moved from Limbo to the container, so that it magically appears. Now, this object can’t be removed from the container, so it will still be there the next time the container is examined. This results in Inform’s default text being printed: “In the [X] is a [Y].” But I don’t want that. I want my own non-default text to be printed.

The trouble is, I can’t use the initial appearance text for this, because my code has already moved the object! So the initial appearance has become irrelevant.

How can I intercept the default output and rewrite it for this one particular object?

I thinking you’re looking for “Rule for writing a paragraph about…” from 18.24?

Good guess, but that doesn’t do the trick. Neither does “Rule for printing the locale description of” in 18.26.

It’s coming from the examine containers rule. I think the only way to interfere with that is to replace it with a new examine containers rule. Trouble is, that’s awfully messy. One really doesn’t want to start overwriting the standard rules in such a basic situation. I’m going to have to look up what the (A) at the end of that line means.

There’s a bunch of approaches imaginable. Here’s one.

Lab is a room. "There's a vase here."

The vase is a scenery container in the lab.
The rose is a thing.

Carry out examining the vase when the rose is off-stage:
  say "You spot a rose."; 
  now the rose is in the vase;
  stop the action.

The examine containers rule does nothing when the rose is in the vase.

Carry out examining the vase when the rose is in the vase:
  say "The rose is in the vase.";
  now examine text printed is true.

I’ll note that I finally remembered to reach for the “the foo rule substitutes for the bar rule when…” assertion… and found (and reported) a v10 bug with it. So that’s why it’s not used above.

But it’s going to be there for the rest of the game. Won’t that edit shut off the entire examine containers rule? I need something more specific. In 14.11 there’s another way to change it – but the example in 14.11 fails to show how to change it back afterward! Criminy.

What about adding onto the “examine containers” rule?

Rule when examining containers:
If the container is the vase:
If the rose is in the vase:
Say “the description you want.”;
Otherwise:
Say “the default thing.”

It might be a little clunky, but maybe?

I’m reluctant to go down that road when I only want to change one line of output. Most of the suggestions in the Docs for how to change the default responses assume that you want to change all of some response (or a bunch of them) for the whole game. If I start kludging into the Standard Rules in order to change one line in reference to one object, not only am I running the risk of screwing up other stuff, but even if I write the code perfectly, will I end up changing 20 things in the Standard Rules? That’s not elegant, and it’s not advisable either.

oops, you’re right.

The examine containers rule does nothing when the noun is the vase and the rose is in the vase.
1 Like

That does the trick. Now I can just add my non-default description to the container object. Note, however, that this works because the container will never contain anything else; it’s either this one thing in it, or nothing. If the container were able to receive other stuff, this solution wouldn’t work.

Well, yeah. You would almost certainly have to replace the examine containers rule if you wanted a more general solution.

Oh I see, yeah.

If everything is right but you want to replace the message tagged (A), you can replace it with something that has an [if the noun is the vase] in it. That’s in 14.11 and I’ve actually used/tested that syntax.

What’s the bug?

Just to clear up one little point, moving a thing in your code doesn’t affect the initial appearance. Usually that only stops appearing when the player picks up the thing, so it becomes “handled”. (But you can manually change the handled status with “now [thing] is handled/not handled” if you want to.)

The reason the initial appearance approach won’t work is because your object is in a container, not directly contained in the room, so it is not picked up by the printing the locale description activity.

1 Like

It only half-works. At the moment, in v10 with “the foo rule substitutes for the bar rule when…, the bar rule is appropriately suppressed but the foo rule isn’t followed.

To follow up on jrb’s points:

  1. There is a standard rule called the initial appearance on supporters rule that makes the initial appearance property matter when describing a not handled object on a supporter. You can write something similar for containers, but note that this would apply generically.

    For printing a locale paragraph about a container (called the vessel)
        (this is the initial appearance in containers rule):
        repeat with item running through not handled things in the vessel which
            provide the property initial appearance:
            if the item is not a person and the initial appearance of the item is not ""
    	        and the item is not undescribed:
    	        now the item is mentioned;
    	        say initial appearance of the item;
    	        say paragraph break;
        continue the activity.
    
  2. It might make sense to create a property to specially mark items that are plainly visible even within a container, and to adjust the new rule above accordingly. (This would allow you to differentiate a rose, which sticks out of the vase, from a key, which does not.)

Summary
    "Rose in Vase"

    Garden is a room.

    A fixed in place container called a vase is in Garden.

    A thing can be prominent.

    There is a rose. "A single rose sits within [the vase]." [substitution prevents double mention of vase in locale description] 

    After examining the vase when the rose is off-stage (this is the summon rose rule):
        now the rose is in the vase;
        now the rose is prominent;
        say "... but as you watch, a rose fades into existence within it.";
        continue the action.

    For printing a locale paragraph about a container (called the vessel)
        (this is the initial appearance in containers rule):
        repeat with item running through prominent not handled things in the vessel which
	        provide the property initial appearance:
	        if the item is not a person and the initial appearance of the item is not ""
		        and the item is not undescribed:
		        now the item is mentioned;
		        say initial appearance of the item;
		        say paragraph break;
        continue the activity.

    Test me with "x vase / look / take rose / put it in vase / look".
  1. The above is for consideration with respect to generic solutions that work with your intuitive sense of the initial appearance property. The built-in machinery’s most applicable access point for special cases is the writing a paragraph about activity (see WWI 18.24), which is functionally similar to the describe() property in Inform 6 in that it takes precedence over normal description logic. (Note that the other stuff above should be left out when taking this approach.)

    Rule for writing a paragraph about the vase (this is the vase description rule):
        if the vase contains the rose:
            say "A splendid rose stands within an ancient urn here.";
        otherwise:
            say "A large urn, clearly centuries old, stands here."
1 Like