Understanding how If/switched on/off works

I’m using the text book but somehow am not getting how the If mechanism works. I’m trying to give two different scenarios depending on whether they’ve got the Electric Lantern switched on or off.

Hiding Place is a room. The description of Hiding Place is "[if Electric Lantern is switched off] Down here is total darkness. You think you hear something moving around down there. You can only see the faint light from the room above. [otherwise/else] Shining the lantern around it looks like this cellar is or was a secret living space for someone. There’s a bed made of a wooden pallet and some folded-up tapestry, some wooden crates serving as table space and a few other signs of a minimal existence. There’s the ladder you came down from of course. And as you move the lamp around, the light falls upon a female human face who with one puff of breath extinguishes your flame. Before you can react you feel something cold and metallic pressed against your throat, a warmth breath now hitting the back of your neck."

Any suggestions?

I can’t read then long line very well on the mobile but I think you can use either [otherwise] or [else].


Yeah, either will work, you just need to pick one.

As a stylistic point, embedding an NPC action into a room description like this feels a little awkward since player action can easily make descriptions happen repeatedly in ways that might not make sense. So I’d probably do that part as an After Going rule or something like that.

(The description also seems to suggest that an item described as an electric lantern can be turned off by blowing out a flame, which might not be what you want!)


Thank you both! That fixed it.

Don’t you need an [endif] at the end as well?

1 Like

I can’t quickly find this documented anywhere, but I think you can get away without using [end if] – Inform will just silently assume it when the text-ending quotation marks appear.

It’s still a good idea to use it, both because it makes your meaning explicit to anyone reading the code, including future you; and it helps avoid an error if you later want to add something in at the end that appears regardless of which branch of the [if ...] condition winds up being followed.


Yup. WI 5.6

That continues until the end of the text, or until an “[end if]” substitution whichever comes first.