[Main]
[Previous]   [Next]

Climbing the Tree - Remapping Behaviour

Since the player will encounter a tree in the clearing, and since examining the tree will tell the player that the tree looks climbable, it is almost inevitable that the player will try to climb the tree; indeed this may seem an even more obvious way of reaching the top of the tree than typing up. But at the moment, the command climb the tree will result in the game responding, "That is not something you can climb." What we need to do is to modify the tree object so that trying to climb it has the same effect as typing up. There are several ways this could be achieved. Perhaps the simplest is to add the following to the definition of tree:
 
dobjFor(Climb) remapTo(Up)  
 
I.e. replace climb tree with an up command. Both dobjFor and remapTo are in fact macros that expand to rather more complex code, but that need not detain us here. What the construction means is "when the current object (in this case the tree) is the direct object of a climb command, replace this action with what would have happened if the player had simply typed up". But an alternative that's worth being aware of, since there can often be situations where it works better, is to use TravelVia and the name of the connector. In this case we could write:
 
dobjFor(Climb) remapTo(TravelVia, topOfTree)  
 
This illustrates a couple of useful things: first, how to use remapTo in the more general case where the verb takes a direct object, and second, how to use TravelVia with a travel connector to achieve movement. However, having pointed this possibility out, we'll revert to the first version, which is what we actually want here. So if you changed your code to try out TravelVia, before going on change it back so it reads:
 
dobjFor(Climb) remapTo(Up)  


Getting Started in TADS 3
[Main]
[Previous]   [Next]