Can anyone tell me what’s wrong with my code here? I’ve put together a test game to try out an idea I had, but I can’t get part of it to work properly.
If I try “absorb chair”, the item is moved correctly to the Hidden room as it should be. But when I try “release chair”, I’m told “You can’t see any such thing.” I’ve looked through the Inform documentation but I can’t figure out what it is I’m doing wrong. Is it an issue with the ‘understand’ command?
Hidden is not in scope. When you understand a thing as “release [something]”, that thing must be in scope. You want “release [any thing]”, and you’ll also need to override the rules blocking the action of reaching into Hidden.
[code]A thing can be free or absorbed. A thing is usually free.
Cell is a room. “An ugly cell.”
A chair is in cell. The description is “A chair.”
Hidden is a room. “Hidden away.”
Absorbing is an action applying to one thing. Understand “absorb [something]” as absorbing.
Releasing is an action applying to one thing. Understand “release [any thing]” as releasing.
Rule for reaching inside Hidden when the action name part of the current action is the releasing action: allow access. [This flourish ensures you won’t be able to, for instance, affect something that has been absorbed, other than by the releasing action.]
After absorbing chair when chair is in Cell:
move chair to Hidden;
now the chair is absorbed;
After releasing chair when chair is in Hidden:
move chair to Cell;
now the chair is free;
The “touchable” requirement (which is what “visible” annuls) is not applied when matching the player’s command! The parser does that matching by iterating through the current scope and checking objects.
Touchability is checked later, in the basic accessibility rule.
Wait, I see the confusion. Inform uses the term “visible” in two ways, and we’re not talking about the same one.
“Visible”, as an adjective applied to things, means in-scope. This usage is defined in the Standard Rules:
The verb to be able to see (he is seen) implies the visibility relation.
Definition: Something is visible rather than invisible if the player can see it.
If you chew down through through the implementation of the visibility relation, you’ll find – first, a bad headache, and then a call to the I6 routine TestScope(), which does what you think.
However, the term “visible” in defining an action does not have this meaning. If you define three actions:
Foo1 is an action applying to one thing.
Foo2 is an action applying to one touchable thing.
Foo3 is an action applying to one visible thing.
…the third line does not mean “apply an extra visibility check”.
In fact you’ll find that Foo1 and Foo2 are treated exactly the same by the parser. (That is, the action requirement for new actions defaults to “touchable”) They have a flag which means that a touchability check occurs (in the basic accessibility rule).
And Foo3 is exactly the same, except that this flag is omitted! So that’s what I meant. The action does not necessarily apply to touchable things.
(It wouldn’t make sense to speak of a thing being not-necessarily-touchable – a thing either is touchable or it isn’t!)
No, no, that is exactly what I meant and we are talking about the same thing. ‘Visible’ in the context of defining an action means in-scope. It means the action can apply to anything that is already in scope. I’ve assumed they choose the word ‘visible’ because, unless you muck about with it, everything ‘in scope’ is also ‘visible’. That the items in scope are not necessarily touchable is rather secondary.
“Touchable” in that context means the action can apply to anything that is already in scope and also touchable. Every action applies to things that are in scope, with optional extra restrictions. In-scopeness isn’t a point of distinction between actions. (And if you want to change the scope of your action, you don’t do it when defining the action. You do it when definining the grammar.)
So it is clearest to not mention scopeness at all, when explaining action definitions. (Instead, discuss it with respect to grammar, which is where it applies.)
What about actions that apply to ‘any thing’? In-scope is the middle option, and includes all the things in the object graph starting from the location of the actor. Commands can apply to things that are not in scope.
When you define grammar to match ‘any thing’, the scope is the entire object tree.
The confusion seems to arise from the assumption that there’s “the scope” which you can either adhere to or ignore. That’s not true, actions always apply to a scope, defined by their grammar. So when you say “Understand “think about [any thing]” as thinking about”, you’re defining the scope of the noun token to be the entire object tree.
Bumping this again as I’ve ran into another (slight!) snag.
When I try to absorb something I’ve written a response for, I get the correct result, but when I try something that doesn’t have a response I’d written, I get nothing aside from another line with the cursor on it.
Do I need to write a response for every single item or is there a way to cover them all with one simple command?