Hi, I am wondering how to report taking something from on top of a supporter or from inside a container. My two best guesses based on the verbs present in default Inform 7 don’t work (below, neither Foo nor Bar is printed).
Example Location is a room.
A box is a container in Example Location.
A ball is a thing inside the box.
A table is a supporter in Example Location.
A cup is a thing on top of the table.
Report taking something when the noun is inside something or the noun is on top of something:
say "Foo."
Report removing something from something when the noun is inside something or the noun is on top of something:
say "Bar."
Thank you!
These rules aren’t going to work because, by the time the Report stage fires, the player already has the thing. So it’s not inside something or on top of something anymore! And we can’t use the “was,” which checks whether the condition held at the beginning of the turn, because that doesn’t work with temporary variables like “the noun.”
There are probably a lot of ways to do this but I thought of a fancy one:
Example Location is a room.
A box is a container in Example Location.
A ball is a thing inside the box.
A table is a supporter in Example Location.
A cup is a thing on top of the table.
The taking action has an object called the supporter taken from. [making this an object rather than a supporter so that the default value doesn't get set to the first supporter defined.]
The taking action has an object called the container taken from. [ditto]
Setting action variables for taking:
if the noun is in a container (called the enclosure), now the container taken from is the enclosure;
if the noun is on a supporter (called the platform), now the supporter taken from is the platform.
After taking something when the supporter taken from is not nothing: say "You take [the noun] from [the supporter taken from]."
After taking something when the container taken from is not nothing: say "You take [the noun] from inside [the container taken from]."
See §12.10 on Action Variables. So this creates variables that remain set for the duration of the action–unlike temporary variables which only last for a rule–so you can reference them in all the rules.
Also I changed the Report rules to After rules, which by default stop the action processing, so you don’t duplicate with the “Taken” message.
1 Like
That’s really neat! Thank you.