I’d like to generalize guarding something. Here is what I have:
protection relates one person (called the protector) to one thing.
The verb to guard (he guards, they guard, he guarded, it is guarded, he is guarding) implies the protection relation.
Instead of touching something that is guarded by [b]someone (called the guardian) in the presence of the guardian:[/b]
say "That's not a good idea."
This does not compile.
I get this message:
Though – this will work if I take away the generalization and tie this to a proper person.
I think what is happening is that Inform is reading someone in the presence of the guardian as a person who is inside something called ‘the presence of the guardian’, and getting confused. You can get around this by breaking off the “in the presence” clause and making it part of the body of the rule.
Before touching something that is guarded by someone:
if the protector of the noun can see the player, say "That would not be a good idea." instead.
“Can see the player” is essentially the same condition as “in the presence of” – it’s a bit more flexible than simply checking if the protector is in the location, because now you can have an invisible docent, or a docent who is watching from another room.
I’ve made it a before rule because a before rule continues on with the normal action-processing unless you specifically tell it not to, while instead rules always stop the action unless you specifically tell it not to. The same rule as an instead rule would have to be written:
if the protector of the noun can see the player, say "blah blah";
otherwise continue the action.
The before rule written above is exactly equivalent, but less wordy.
My doors do not need to be “touched” to be opened; which surprises me a little.
Perhaps I am doing something to override that with this?
Before going through a closed door (called the blocking door):
say "(first opening [the blocking door])[line break]";
silently try opening the blocking door;
if the blocking door is closed, stop the action.
“Touching” is a specific action, distinct from other actions. When you write a rule that fires before, after, or instead of “touching something”, it’s testing to see if the action is, literally, touching – in other words, that the player typed >TOUCH DOOR. If you want to capture other actions that imply touch (like opening, pushing, pulling, etc.), you will need to write your rule to include them, too.
Instead of doing anything other than examining the door: blah, blah.
Be careful not to get this confused with “touchability”. Inform does test whether an object is “touchable” for the verbs for which that would be logical, but what it’s mainly testing for is whether the object referred to is inside a closed container or in a different room. (This is so you can have things like a key inside a locked glass box, so the key is visible and referable-to, but not touchable.)
The similarity in nomenclature is unfortunate, but touching and touchability are different things. Testing something’s touchability does not simulate the touching action. However, the touching action does test for touchability, as does the opening action.
A handy way to trap any action that would require a touchable noun is:
Instead of doing something to the door when the current action requires a touchable noun: blah, blah.
Recommended reading: Chapters 6.10, 7.9, 12.16-12.18 of the documentation.