Conditional Text Complication

Hi again. This is a two-pronged question about conditional text.

[if the plate, log, or knife are not in the clearing and the player does not enclose the plate, log, or knife] blah blah[end if]

Doesn’t work or any variation I can think of.

The second question is, are objects enclosed by the player potentially “in the clearing” or does the program see the player’s inventory as a separate location regardless of what room they are in and the second part of my invalid text is unnecessary.’

“In the clearing” means, I think, directly in the clearing–not inside something else which is in the clearing. If something is held by the player, it’s not “in the clearing.”

I’m not sure if you want “or” or “and,” but you can do something like this:

say "[if (the plate is not in the clearing) and (the log is not in the clearing) and (the knife is not in the clearing)]blah[end if]".

Watch out for booleans. They don’t work like language. :slight_smile:

When you want to make sure that a thing is neither in A or B, be sure to check it is not in A AND B.

Came to this conclusion myself after bashing my head over some code for like three hours a few days ago.

Don’t know about the specific code, tho, sorry because it seems I’ve already forgot all of my Inform7.


Sometimes making adjectives and definitions can simplify conditions.

Off top of my head: “The location of something” always means the room despite other layers of enclosure. “The holder of something” means the immediate thing enclosing it which can be the location, a container, a supporter, or the player (in inventory or worn). I believe “held by the player” means in inventory of the player or worn by the player, but not inside another container which is held.

1 Like

You’re encountering a lot of little tricks at once here.

The first is that if clearing is a location and you check if BLAH is in the clearing, that specifically means to Inform that BLAH must be sitting in the clearing. BLAH can’t be in a cupboard in the clearing. It can’t be held by someone in the clearing. The directly enclosing parent of BLAH must be the specified location, if you use the test ‘if BLAH is in LOCATION’.

However, enclosure is a test you can apply to anything. Locations, people, objects, etc.

This means if you want to test if a knife is in the clearing anywhere at all (carried, in a bag, locked in a box that’s invisible… anywhere) you can use a test like

if knife is enclosed by the clearing:

Separately, here’s a cheat sheet I made showing which concepts test what regarding things the player’s holding, carrying, wearing etc.:

So once you’re on top of that, you may need to look at the boolean logic of what you want. If your sentence with ‘or’ and commas doesn’t work, try expanding it in a really strict way. e.g.

‘if the plate is not enclosed by the clearing and the knife is not enclosed by the clearing and…’ etc.

There’s ultimately probably an easier way to specify the condition you want, but I couldn’t say what it will be yet as I’m not sure what condition you want.



Thank you everyone for you thoughtful replies.

I apologise for not adding more detail.

Essentially what I am trying to achieve is a responsive description of a clearing. As the player removes things I change the description to reflect this. However, when they are all gone, I want to give a different response altogether.
So, it doesn’t make anything “happen” aside from adjusting the printed text.

1 Like

The system for writing room descriptions is fairly complex. It has a number of moving parts that provide hooks to change the main room description under different contexts, or to change the description of various objects according to their situation in the room. Many patterns of produced text are automatic unless overridden through the use of hooks.

To understand and make use of these hooks, it is first necessary to understand some basic concepts within Inform such as the nature of rules and rulebook processing, the nature of activities and activity rule processing, and the overall flow of action processing. Here’s the shortest list of documentation topics that I could come up with:

  • Writing with Inform
    – WI 11.1 What are phrases?
    – WI 12.2 How actions are processed
    – WI 18.1 What are activities?
    – WI 18.2 How activities work
    – WI 18.3 Rules applied to activities
    – WI 19.2 The preamble of a rule

  • Recipe Book
    – RB 3.1 Room Descriptions
    – RB 6.4 Looking

The Recipe Book may be the place to start if you learn better by example.

The basic tools available, in approximate order of complexity, are:

  1. Writing a static room description that will always produce the same output.

  2. Writing a conditional room description that will produce varying output based on conditionals within the room description text. (Some examples are given by others above.)

  3. Using properties such as scenery or undescribed to prevent automatic listing of certain objects, or using the initial appearance property to give an object a special description in its original context.

  4. Including objects as text substitutions within a room description tol prevent subsequent automatic mention of items, which can be used in conjuction with conditionals in the room description, e.g. “... The walls are lined shelves[if the widget is on the shelf] -- on one of which you see [the widget] you have been looking for[end if].

  5. Using for writing a paragraph activity the <X> rules to give certain items a special description under some or all circumstances, e.g. For writing a paragraph about the pile of gold: say "A pile of golden coins sparkles in the light of your torch."

  6. Modifying the responses of built-in room description rules to customize the feel of generic descriptions.

  7. Using rule preambles, rule ordering, and/or conditionals and substitutions in text produced by rules to vary whether a special description is given at all and what form it takes under various conditions. The lightning rod is undescribed. For writing a paragraph about the lightning rod during Sunset: say "The setting sun casts a the shadow of the barn across the field. A thin, dark spike extends from the shadow barn's roofline along the ground, pointing directly at the well."

That’s not a quick answer; it’s a broad answer to match your broad question. If you describe more about the specific effect(s) that you are trying to achieve, you may get more targeted advice.

Given the brief description of what you want, I would suggest something along the lines of:

Definition: A room is empty if it contains exactly one thing [the player] and the player is in it.

Museum is a room. "[If the museum is empty]A bare and echoing hall[otherwise]A magnificent chamber housing displays of ancient office technology[end if]."

A stapler is in the Museum. "Under a spotlight is a curious object, like lopsided tongs." Understand "lopsided" or "tongs" as the stapler.

A rolodex is in the Museum.

After choosing notable locale objects for the Museum:
	set the locale priority of the stapler to 4. [default is 5, lower is better down to 1; ensures stapler listed first]

Rule for writing a paragraph about the rolodex when the rolodex is in the museum:
	unless the stapler is handled:
		say "The tong's oblong shape points to a cylinder of paper cards mounted on a chipped plastic spindle in the center of the room. The top cards lie open, revealing handwritten data.";
		say "An unusual device is in the center of the room. It looks like a cylinder of paper cards, on each of which information has been written by hand."

After dropping the rolodex in the Museum:
	say "You carefully restore the venerable database to its place of honor."

Lobby is south of Museum.

Test me with "take rolodex / look / drop rolodex / look / take stapler / look / take rolodex / look / s / drop rolodex / look / drop stapler / look".

EDIT: Example code corrected.

1 Like

Make sure you understand the relations involved. “in” and “enclosed by” and “held by” and “in the location” might seem like the same thing but there are differences for Inform 7’s purposes (I think I’ve got these right):

  • Carried: in inventory, not worn - this also works for an NPC ‘carried by Bob’
  • Held: directly contained by without additional layers of enclosure - held by the the player, location, held by the jeweled box (things worn by the player are considered directly “held” also) If you say just “held” the parser infers “by the player” but you can say “held by Bob” also.
  • Enclosed by: things held or inside somewhere, regardless of layers of containment
  • In: like held, direct containment with no additional layers of containment
  • In the Location [or a room]: means “held by the current room [requested room]” if you want anything matryoshka-dolled inside say “enclosed by the location [room]” - if you ask for “The location of [something]” the parser will return the room no matter what the object in that room may also be contained by within the room. If you ask for “the holder of [something]” it will return the item directly enclosing the thing, whether the room, a player, a supporter, or a container.

Note the moss on the boulder and the treasure in the crate are not considered “clutter” if they’re within the Clearing but contained or supported by something else. If the crate is sitting in the clearing it’s defined as clutter, but not after the player picks it up (it’s no longer “held” by the location). If I take the treasure from the crate and drop it on the ground, it’s then considered clutter. Definitions are great to apply a varying adjective that depends on world-state. Anything that fits the definition can be referred to as “clutter” or “a clutter thing”.

Cleaning up is an action applying to nothing. Understand "clean up" as cleaning up.

Check cleaning up:
	if no clutter thing is touchable:
		say "This place is pretty tidy." instead;
		say "What's clutter here?";
		repeat with C running through clutter things in the location:
			Say "...[the C]";
			try taking C.

And I can use the “clutter” definition to vary the description of both rooms and exclude things in the definition like the boulder and the player.


Carrying (‘if the player carries…’) means directly held by a person, but not worn.
Wearing (‘if the player wears…’) means directly held by a person, and worn.
Possession (‘if the player has…’) means worn or carried by a person.

For exhaustive detail, see here.