I have a character that is blindfolded. So when a user inputs “Examine”, I want to be able to say, “You cannot see the tunnel. Did you forget that you are blindfolded?”
This is what I used:
Instead of examing the tunnel:
say “You cannot see the tunnel. Did you forget you are blindfolded?”
Instead of examining [something]:
say "You can’t see anything. Did you forget you are blindfolded?
If I’m getting the Inform 7 right, that would cover any attempt to perceive anything at all.
(edit): I think the problem is that the system checks for the existence of the target before it even checks for the Instead rule. If there’s no object, it fails by saying it doesn’t exist. I think using [something] will pass as long as there’s a text string after examine, so the existence of that thing won’t matter.
The [something] here is actually doing nothing at all—text in square brackets outside a text string is a comment, so the compiler ignores it completely!
The trick is, Inform considers “examining” and “examining something” to be the same, so “instead of examining [something]” works completely by accident: the [something] gets removed, but “instead of examining” is a perfectly legal rule header on its own.
I’d assumed the documentation keeps them there as a reminder. Thanks for pointing out the reality.
(edit) Double-checking - it’s the quotations that are needed to make bracketed words functional, yes?
Excellent. Thank you everyone for your fast response. It will take me awhile to learn but it is enjoyable. Thank you Interactivefiction for the help. It worked pretty well.
Did a little more with this and added a container with a hidden object in it to be certain that searching objects (versus rooms) works as expected.
A blindfold is a thing. The description is "It is a black cloth blindfold."
Tunnel is a room. The description is "This is a long tunnel carved from stone."
A chest is an openable closed container in the Tunnel. The description is "It is a wooden chest."
The chest contains a glass sword. The glass sword is undescribed.
The description of glass sword is "This is a glass sword, almost invisible to the eye."
Understand "examine [any room]" as searching.
Instead of searching:
If the player is wearing a blindfold:
say “You cannot see the [location]. Did you forget you are blindfolded?”;
stop the action;
If the noun is an open container:
Now all objects in the noun are described;
continue the action;
continue the action.
Instead of examining anything:
If the player is wearing a blindfold:
say “You cannot see the [noun]. Did you forget you are blindfolded?”;
stop the action;
continue the action.
Instead of looking:
If the player is wearing a blindfold:
say “You cannot see the [location]. Did you forget you are blindfolded?”;
stop the action;
continue the action.
After taking off a blindfold:
try looking.
The player wears a blindfold.
This basically plays out as follows:
You cannot see the Tunnel. Did you forget you are blindfolded?
>l
You cannot see the Tunnel. Did you forget you are blindfolded?
>examine tunnel
You cannot see the Tunnel. Did you forget you are blindfolded?
>examine blindfold
You cannot see the blindfold. Did you forget you are blindfolded?
>remove blindfold
Tunnel
This is a long tunnel carved from stone.
You can see a chest (closed) here.
>examine chest
It is a wooden chest.
>search chest
You can't see inside, since the chest is closed.
>open chest
You open the chest, revealing nothing.
>search chest
In the chest is a glass sword.
>examine sword
This is a glass sword, almost invisible to the eye.
Made a quick edit based on Andrew’s suggestion, it works well and causes the player to look at the current room in response to removing or taking off the blindfold.
You cannot see the Tunnel. Did you forget you are blindfolded?
>take off blindfold
Tunnel
This is a long tunnel carved from stone.
You can see a chest (closed) here.
Additional edit to prevent the objects in the container from being made visible by searching the chest while it is closed.
A good idea! Question for you, would cases for when player is blindfolded be better in Before statements versus Instead? I read that Instead is really for blocking actions and that the combination of Instead + continue the action should be written as a Before statement.