How to trigger different room descriptions efficiently when objects are not there? Also multiple objects?

Right or wrong, I’m trying to present a room description without following it with a listing of all the things in the location I’ve just described.

The problem is that I need to modify that description to reflect if the objects are there or not. In this particular room there is a wheelbarrow and rake. This means I need to have a response for everything there, rake gone, barrow gone, both gone. This creates a bunch of code if I want the description to be responsive.

I have two questions:

  1. Is this just the way it is and I’m doing it right?

  2. What is the correct syntax for “If the rake and the wheelbarrow are not in the side yard:” because this is wrong?

Report going to the side yard:
	If the rusty wheelbarrow is not in the side yard:
		say "The path through the side-yard is badly overgrown. Dried and brittle foliage clings to your clothing as you pass, setting off the sounds of scuttling in the darkness. A worn out [rake] sits discarded by the path.";
		stop the action;
	otherwise:
		say "The path through the side-yard is badly overgrown. Dried and brittle foliage clings to your clothing as you pass, setting off the sounds of scuttling in the darkness. A [rusty wheelbarrow] and worn out [rake] sit discarded by the path.";
		
Report going to the side yard:
	If the rake is not in the side yard:
		say "The path through the side-yard is badly overgrown. Dried and brittle foliage clings to your clothing as you pass, setting off the sounds of scuttling in the darkness. A [rusty wheelbarrow] sits discarded by the path.";
		stop the action;
	otherwise:
		say "The path through the side-yard is badly overgrown. Dried and brittle foliage clings to your clothing as you pass, setting off the sounds of scuttling in the darkness. A [rusty wheelbarrow] and worn out [rake] sit discarded by the path.";
		
report going to the side yard:
	If the rake and the wheelbarrow are not in the side yard:
		say "The path through the side-yard is badly overgrown. Dried and brittle foliage clings to your clothing as you pass, setting off the sounds of scuttling in the darkness.";
		stop the action;
	otherwise:
		say "The path through the side-yard is badly overgrown. Dried and brittle foliage clings to your clothing as you pass, setting off the sounds of scuttling in the darkness. ";

How about this?

The description of the side-yard is "The path through the side-yard is badly overgrown. Dried and brittle foliage clings to your clothing as you pass, setting off the sounds of scuttling in the darkness."

Rule for listing nondescript items of the side-yard: say "[A list of marked for listing things in the side-yard] [sit] discarded by the path."

“Listing nondescript items” is what normally prints the “you can also see…” paragraph; here, I’ve rewired it for this specific room to print a different sort of paragraph instead.

Maybe this helps. When you create each item, you can define its initial appearance:

"Initial appearance"

The Kitchen is a room. "The smell of Hirakawa's teriyaki sauce is still everywhere."

The knife is in the kitchen. "A razor sharp tanto knife lies among the other, less lethal cutlery." The description of the knife is "Every samurai's plan B."

[Another way of writing it is:]

The sushi roll is in the kitchen. The description of the sushi roll is "Salmon and avocado." The initial appearance of the sushi roll is "A roll of sushi has rolled under the kitchen table."

Each item has its own paragraph in the room description (or when LOOKING). If that’s something you don’t like, you will need to write a rule—I’m afraid I don’t remember how to be more masterful on this…

1 Like

There’s an extension designed to help with this very issue: Room Description Control by Emily Short.

To quote from the documentation: “This extension is designed to help resolve certain challenges in Inform’s default room description, allowing items to be more flexibly concealed and the order in which objects are mentioned to be fully controlled by the author.”

Conjunctions in Inform 7 usually have to join complete conditions, not individual nouns. Try “If the rake is not in the side yard and the wheelbarrow is not in the side yard.”

The underlying thing from Daniel’s solution is that, if a thing has been mentioned in the room description using “[rake]” or something like that, it won’t show up in the you-can-also-see paragraph.

If the rake and wheelbarrow are the only things you want to be described as lying by the path, you can make an adjective for that and use that in the description:

Front yard is a room. Side yard is north of front yard.

A thing can be path notable.

The worn out rake is a path notable thing in side yard. The rusty wheelbarrow is a path notable thing in side yard.

The player carries a rock.

To sit is a verb.

The description of side yard is "The path through the side-yard is badly overgrown. Dried and brittle foliage clings to your clothing as you pass, setting off the sounds of scuttling in the darkness[if a path notable thing is in the side yard]. [A list of path notable things in the side yard] [sit] discarded by the path[end if]."

It’s better to put this in the room description rather than a report going, because the player might look while they’re in the room. If you want this to be printed only when the player goes to the room, it’s probably better to use “After going.” After rules automatically stop processing the action unless you tell them not to, so you can use them to substitute for the standard action output, and use Report to supplement the standard action output.

Also, the way you have the rules set up, I kind of doubt they’d all work as desired. If neither the rake or wheelbarrow is in the yard, the first rule will fire, see that the wheelbarrow isn’t in the yard, print the message that the rake is in the yard, and stop. If the wheelbarrow is in the yard, you get a message from the first rule, it goes on to the second rule and then you get another message depending on whether the rake is in the yard or not. If both are in the yard, you wind up with messages from all three rules.

One way to avoid this is to put the conditions on the rule in the rule heading. If you write “After going to the yard when the wheelbarrow is not in the yard and the rake is not in the yard:”, that rule will fire only when neither is in the yard–if either one is in the yard, Inform will ignore it. In general if you want a rule to do something only in certain conditions, it’s a good idea to load those conditions into the rule header if you can.

An object’s initial appearance property is really helpful because you can write an entire paragraph about it which will exist under the room description until the player takes or moves the object, after which it is described normally with “You can also see…” These paragraphs can be an important prompt for the player for notable objects and give you an opportunity to extend the story and room description in a collapsible manner since you can establish additional room description flavor in them. I believe that’s the intention of initial description, but not necessarily the “way you’re supposed to do it.”

Example

Study

Mr. Boddy’s study is tastefully appointed in walnut mahogany with brass lighting fixtures. A passage opens toward the Entry Hall to the east, and the Library is around a corner to the south.

One brass candlestick is on the coffee table. Just one? Don’t these come in pairs? And don’t candlesticks usually belong in the Dining Room? There’s not even a candle in it. Odd.

x coffee table

A marble coffee table. You’ve seen various ones much like it in other locations around the manor.

On the coffee table is a candlestick.

take candlestick

Taken.

l

Study

Mr. Boddy’s study is tastefully appointed in walnut mahogany with brass lighting fixtures. A passage opens toward the Entry Hall to the east, and the Library is around a corner to the south. This is where you found a candlestick separate from its twin earlier. Someone (Professor Plum?) may have initially moved it here.

x candlestick

You recall Professor Plum admiring a similar set of candlesticks that were set aside on the banquette during dinner. He even polished a smudge off one…but it had a candle in it before, and was stored with it’s matching twin. Why separate them?

drop candlestick

Dropped.

l

Study

Mr. Boddy’s study is tastefully appointed in walnut mahogany with brass lighting fixtures. A passage opens toward the Entry Hall to the east, and the Library is around a corner to the south.

You can see a candlestick here.

put candlestick on table

(first taking the candlestick)

You put the candlestick on the coffee table.

l

Study

Mr. Boddy’s study is tastefully appointed in walnut mahogany with brass lighting fixtures. A passage opens toward the Entry Hall to the east, and the Library is around a corner to the south.

On the coffee table is a candlestick.

Code
The Study is a room. "Mr. Boddy's study is tastefully appointed in walnut mahogany with brass lighting fixtures. A passage opens toward the Entry Hall to the east, and the Library is around a corner to the south[if the candlestick is not in the location and the candlestick is not on the coffee table]. This is where you found a candlestick separate from its twin earlier. Someone (Professor Plum?) may have initially moved it here[end if]."

furnishings is scenery in the study. The description is "Tasteful." Understand "walnut/mahogany/brass/light/lighting/fixture/fixtures" as furnishings. 

A coffee table is a supporter in the study. It is scenery. The description is "A marble coffee table. You've seen various ones much like it in other locations around the manor."

A candlestick is on the coffee table. "One brass candlestick is on the coffee table. Just one? Don't these come in pairs? And don't candlesticks usually belong in the Dining Room? There's not even a candle in it. Odd." The description is "You recall Professor Plum admiring a similar set of candlesticks that were set aside on the banquette during dinner. He even polished a smudge off one...but it had a candle in it before, and was stored with it's matching twin. Why separate them?"
Notes
  • I did the reverse of the initial question - adding a mention of the candlestick to the main room description when it’s not there to remind the player, and showing how multiple conditions need to be separated. It’s not “if the candlestick is not in the location or on the coffee table” it’s “if the candlestick is not in the location and the candlestick is not on the coffee table”.
  • Note in the room description the technique of reserving the period until after the condition in brackets. This is the surest way to control line breaks as the period will generate one. I want the paragraph to run together if it prints the conditional text, so the final period left outside brackets at the end of the condition will always show and generate the line break. Not ending the main room description with the period (and putting it at the start of the conditional) means the room description will end with one period or the other whether the conditional fires, and if it does, the final period ends that text.
1 Like

Haha, yeah. It took me a while (and several questions on this forum) to wrap my head around this. :laughing:

2 Likes

Thank you for the three-pronged explanation. Your solution is ideal for my purposes, as I have decided to place the wheelbarrow elsewhere.

I would still be interested to know how the code would be modified if there were two different items in the location.

1 Like

That’s a great trick, too.

I’m wondering: is this absolutely equivalent to defining something as scenery?

Thank you for clarifying that.

That’s really great and so efficient.

No, not at all. It’s equivalent to setting the item “mentioned” in a paragraph-writing rule. It removes the item from the you-can-also-see list for the current look action only.

Scenery is a whole different ball of wax. Setting something scenery makes it untakeable. It’s also permanent; the item remains unshown in all future look actions.

1 Like

Thank you for that link. I’m not sure I have a full grip on the particulars so I’ll have to spend some time with it. It’s great to see Emily did the work to create a way to make the coding of this more efficient.

I think that writing good, natural-reading, flexible room descriptions is one of those skills you don’t know you haven’t got until you start writing IF. (Certainly that was my experience!) :slightly_smiling_face:

1 Like

@zarf, what is the difference between the “current” and “all future” look actions?

“mentioned” is cleared before each LOOK action. You set it in a rule that happens inside the LOOK, such as an initial description or a writing a paragraph about rule. It affects the last stage of that LOOK action, the “you can also see” paragraph.

“scenery” is never cleared, so it applies forever.

Using your setup as a template, have I implemented this correctly (tidying up aside)? It seems to be working but I don’t have a great grasp on the subtle ways it may now be wrong.

the BACK GARDEN is southeast of the Side Yard. the BACK GARDEN is east of the KITCHEN. the BACK GARDEN is north of the NEGLECTED ORCHARD. the BACK GARDEN is west of THE CORRAL. "Dim light from a kitchen window creates deep shadows in the backyard of the mansion. It is only slightly less overgrown than the side yard of the house appears to be. A well used path cuts across the browned grasss heading further East towards a well maintained corral outside an old barn. An overgrown path heads south into an neglected orchard[if the old wheelbarrow is on the overgrown path]. past an [old wheelbarrow][end if]."

furnishings is scenery in the back garden. The description is "Tasteful." Understand "walnut/mahogany/brass/light/lighting/fixture/fixtures" as furnishings. 

An overgrown path is a supporter in the BACK GARDEN. It is scenery. The description is "This overgrown path leads towards the neglected orchard. Why would anyone want to go there?!."

An old wheelbarrow is on the overgrown path. The description is "This wheelbarrow has seen better days but appears to be serviceable, at least in the short term."


the pit is room. The pit is south of the BACK GARDEN. "Ew, a pit".

Thanks! Yes, that makes sense!

I’d make the overgrown path an enterable supporter so the player can stand on it if they wish.

You might predict that the player might want to FOLLOW PATH which isn’t an implemented action.

Untested, but:

following it is an action applying to one thing. Understand "follow [something]" and "walk on [something]" and "walk along [something]" as following it. 

a thing can be followable. the overgrown path is followable. 

Check following it:
     if the noun is not followable:
          say "[The noun] [don't] really lead anywhere." instead.

Check following the overgrown path:
     try going south instead.

Also be aware you have mapped both “the pit” and “NEGLECTED ORCHARD” south of BACK GARDEN

Unless you’re intending non-reciprocal directions (which is doable in I7) you might want GARDEN PIT is down from NEGLECTED ORCHARD possibly.

Also, you don’t really need this line since none of it is present from the example.

  • say "[The noun] [don't] really lead anywhere." instead. - [don’t] is a substitution token that will match your noun: “The hedgemaze doesn’t really lead anywhere.” “The breadcrumbs don’t really lead anywhere.” To do this in a default message, you put the plural in brackets.

Thank you for the speedy reply. The tidied up version made all the changes you identified so it was great to get that right and have a comparison to check against.

I’ll look into an enterable containers. I created a climbed and unclimbed state which now seems unnecessary.

While we’re at it, is there a simple way to keep all the initial appearances of a room’s objects in the same paragraph?