Rule for printing the description of an [adjective] thing

i’m honestly doing my damndest here to thoroughly scour the documentation for help before posting, but i’m beginning to go a little crazy. It feels like any time i try something with exactly the same structure and format as the docs, Inform throws an error.

My current struggle:

[code][spoiler]“Preposterousness” by test

The tortureCell is a room.

A thing can be preposterous or reasonable. A thing is usually reasonable.

The informLearningCurve is a preposterous thing in the tortureCell.

[Rule for printing the description of something that is preposterous:]
[Rule for printing the description of something when it is preposterous:]
[Rule for printing the description of a preposterous thing:]
[Rule for printing the description of a thing when the thing is preposterous:]
[Rule for printing the description of a thing (called the target) which is preposterous:]
[Rule for printing the description of something (called target) which is preposterous:]
if target is preposterous:
say “This is preposterous.”;

test me with “x informLearningCurve”[/spoiler][/code]

All of the commented statements throw a punctuation error. What am i missing?

It looks like you’re working by analogy with “printing the name of…” rules?

There’s a particular activity in Inform called “printing the name of”, implemented because printed names come up in so many different situations that you’ll likely need to fine-tune it. Descriptions, on the other hand, are really only relevant to the “examining” action. So there’s no analogous “printing the description of” activity, since you could just override “examining”:

Instead of examining a preposterous thing: say "Don't bother looking more closely."

Or just put a condition in the description variable:

The description of the fish is "A [if preposterous]preposterous[else]perfectly ordinary[end if] fish."

You could also implement a new activity if you really wanted to; this is example 335, “Crusoe”, in the manual. But that seems like overkill.

It’s slightly more complicated than just overriding examining (which i’ve already discovered, because that’s what i tried originally!).

What i’m trying to accomplish is a game where the player can turn the lights off in various rooms, but still examine and interact with select objects of my (the author’s) choosing. So if a darkened room contains an outlet, a sofa, and a chandelier, i want:

x outlet: “It is pitch dark, and you can’t see a thing.”

x chandelier: “It is pitch dark, and you can’t see a thing.”

x sofa: “You bumble around in the darkness, and your shins eventually find the uncushioned corner of the sofa. Oof!”

(and before you say “how is the player supposed to know about the sofa if the room is dark,” the puzzle relies on the player going into certain rooms, taking note of things that may react differently in the darkness, and returning when the lights are off to check them out.)

So my latest tack was trying to create a quality of a thing called “fumblability” or something. If a thing is fumblable, then it has a special piece of text to read when you examine it in the dark, which replaces the stock “it is dark” phrase. That’s when i got jammed up with the example i posted.

EDIT: Sorry - i should have stated this like a question. HOW do i do this?

The Living Room is a dark room. "This is a darkened living room. You notice an outlet on one wall and a chandelier dangling from the ceiling. A sofa dominates the center of the room."

A thing can be dark-discoverable. A thing is usually not dark-discoverable.
A thing has a text called the dark description. The dark description is usually "You can barely make out [the item described] in the dark."

Instead of examining a dark-discoverable thing when in darkness, say "[The dark description of the noun][line break]"

The outlet is scenery in the Living Room. The description is "It's a typical power outlet."

The chandelier is scenery in the Living Room. The description is "The chandelier hangs from the ceiling over the sofa."

The sofa is a dark-discoverable enterable scenery supporter in the Living Room. The description is "It's a huge, comfortable-looking sofa." The dark description is "You bumble around in the darkness, and your shins eventually find the uncushioned corner of the sofa. Oof!"

The brass lamp is a lit switched on dark-discoverable device. The description is "A shiny brass lamp."
The player carries the lamp.

After switching on the lamp:
	now the lamp is lit;
	continue the action.
	
After switching off the lamp:
	now the lamp is not lit;
	continue the action.

The player carries a newspaper. The description of the newspaper is "Terrifying. You'd rather be playing IF."

Definition: a thing (called T) is nearby if the location of T is the location.

[See example 28 - Down Below]
After deciding the scope of the player when in darkness:
	repeat with T running through all nearby dark-discoverable things:
		place T in scope.
		
Visibility rule when in darkness:
	if examining a dark-discoverable thing, there is sufficient light;
	there is insufficient light.

Test me with "x outlet / x chandelier / x newspaper / x sofa / x lamp / drop lamp / turn off lamp / l / x outlet / x chandelier / x newspaper / x sofa / x lamp / turn on lamp".

This example assumes that you’re willing to accept I7’s default behavior, which is only to give the “It is pitch dark, and you can’t see a thing.” message for objects that are in scope but not visible due to the darkness. This typically consists of things being carried by the player (such as the newspaper), since the player’s inventory remains in scope despite the player being in darkness. However, objects in a dark room (such as the chandelier) will not be in scope and attempting to examine them will produce a “You can’t see any such thing.” message.

You can change this if you want by also placing the other objects in scope in the dark but not making them visible. However, you’ll have to block actions other than examining if you don’t want the player to be able to interact with these objects. As with most things in I7, there are several ways to do this.

Thanks so much for your help, Vince. i think the key phrase i was missing in my earliest experiment was when in darkness. i kept overriding “examine” just fine, but of course, darkness skipped examine altogether.

After playing around with this some more, I’ve discovered a flaw.

Add this to the program and “test me2”:

The metal box is a closed openable container in the Living Room. The red ball is a dark-discoverable thing in the metal box.

The glass box is a transparent closed openable container in the Living Room. The blue ball is a dark-discoverable thing in the glass box.

Test me2 with "x metal box / x glass box / x red ball / x blue ball / x sofa / turn off lamp / x metal box / x glass box/ x red ball / x blue ball / take blue ball / x sofa".

We overzealously place all nearby dark-discoverable things into scope in the darkness, even if they wouldn’t be visible in the light.

The simple solution is just to punt on such objects and change the definition of nearby things to just be objects directly contained in the location. However, this has the downside of not allowing the player to interact with dark-discoverable objects on/in non dark-discoverable supporters/containers (e.g., if the lamp is placed on a table and then switched off).

Here’s a more complex solution that determines whether objects would be visible if there were light (by temporarily and silently adding a light, testing visibility, and then removing the light) and only places “visible-in-light” dark-discoverable objects into scope in the darkness.

[This concept is adapted from the simpler light-meter in example 81 - Unblinking]
The light generator is a lit thing.

light generating is initially false;

Rule for printing the announcement of light when light generating is true: stop.
Rule for printing the announcement of darkness when light generating is true: stop.

Definition: a thing (called T) is visible-in-light:
	let decision be false;
	now light generating is true;
	now the light generator is in the location;
	follow the adjust light rule;
	if T is visible, now decision is true;
	now the light generator is nowhere;
	follow the adjust light rule;
	now light generating is false;
	decide on decision.

[See example 28 - Down Below]
After deciding the scope of the player when in darkness and light generating is false:
	repeat with T running through all nearby dark-discoverable visible-in-light things:
		place T in scope.
		
Visibility rule when in darkness and light generating is false:
	if examining a dark-discoverable thing, there is sufficient light;
	there is insufficient light.

This still allows for the player to stick the lamp in the metal box and close the box, but that’s just a matter of the author not having designated the metal box as dark-discoverable when it probably should be (in order to avoid this lost lamp scenario).

The simple solution might well be enough, since one could reasonably ask “why would something be discoverable in the dark if the thing that it’s in or on isn’t?”