Changing the description of the room based on conditions

I am trying to dynamically change the description of a room if a control panel door is open or closed. For example:

A Control Room is north of the office. “The control room is flashing with all kinds of important looking lights. There is a closed panel door here.”
A Panel Door is here. The Panel Door is undescribed.
The description of the Panel Door is " A small panel door with the DANGER written on it is here."

How can I make the panel door openable and closeable and when it is open change the room description to “The control room is flashing with all kinds of important looking lights. There is an open panel door here.”

I think the parser doesn’t like me using door as that usually defines a door between two rooms. I think I can use the command Now the description of the Control Room is after I figure out how to check the state of the panel door. Any idea how to help me? Thanks.

You will need to define the panel door as a container, as a container can be opened or closed (however you will have to explicitly say that it is openable)–

A panel door is here.  It is a container and scenery.  It is openable and closed.

‘Scenery’ will prevent a message saying ‘You can see a panel door here.’ But also, you will need to include a message in the room description to tell the player that it is there (like you already have). Incidentally, you won’t need the ‘undescribed’ line, as the door would be scenery (which would not rate a ‘you can also see’ line).

A Control Room is north of the office. “The control room is flashing with all kinds of important looking lights. There is [if the panel door is open]an open[otherwise]a closed[end if] panel door here.”

In the brackets are text substitution conditions, much like conditions in a rule, placed into quoted text. The [end if] signals the end of the rule–text after it gets printed regardless of what goes on in the rule.

I hope this helps.

1 Like

Thanks. What if I wanted the description to be something completely different when the door is open?

It’s the exact same logic, just tweak what text it applies to:

A Control Room is north of the office. “[if the panel door is open]Here's a completely different description you can fill out however you want[otherwise]The control room is flashing with all kinds of important looking lights. There is a closed panel door here[end if].”

Mike’s answer here is probably the best thing. You could use an After rule (such as 'After opening the panel door: now the description of Control Room is…), but then you would have to write another After rule for when the player closes the panel door back, to revert back to the original description.

1 Like

Great! Thanks!

One thing about containers, and the ‘openable’ property–there are some containers that are ‘not openable’ or ‘unopenable’, particularly those that are permanently open (such as a ceramic mug, a birdbath, or a swimming pool)–thus cannot be closed. So openable not only means that a container can be opened (by the player), but also closed (by the player). You can make containers that are closed and unopenable, but they would lack a practical use in the physical world. But you know in IF, all is possible.

1 Like

What about a closed, unopenable, transparent container? Maybe an animal’s cage, or a perspex box you have to smash to pieces, or just something magical… :slight_smile:

2 Likes

Yeah, though that feels to me like something you’d often just fake with a description instead of actually implementing…

1 Like

The transparent closed container case is pretty common, actually. It allows the contents to be in scope (examinable) but not reachable.

Whether the container is “openable” or “unopenable” is then just a question of whether you want the OPEN BOX command to work. Plenty of cases where it doesn’t, as Jonathan said.

2 Likes

Yes: consider a display case in a museum with artifacts under glass. If you don’t want the player to ever touch the contained objects, but be able to examine the case and the objects.

Another more weird example - a game where the player is psychic and can examine “thoughts” inside people’s heads. You could implement that headspace as a closed, unopenable, transparent container but change what physically implemented thought objects are inside each one periodically through the course of the game.

4 Likes