Remap
|
We have already encountered remapping via the remapTo macro; it's used when we want to remap a command on one object to a different command involving the same or maybe different objects (or even no objects at all). So, for example, on the tree object we earlier defined:
|
dobjFor(Climb) remapTo(Up)
|
|
|
remapDobjClimb = [UpAction]
|
|
|
dobjFor(Enter) remapTo(TravelVia, outsideCottage.in)
|
|
|
remapDobjEnter = [TravelViaAction, outsideCottage.in]
|
|
For example, the library class PathPassage remaps Take to TravelVia (since take the path normally means follow the path). But this has the unfortunate side-effect that pick up the path is also interpreted as traveling via the path. Suppose that you didn't want this in your game, so you defined:
|
|
dobjFor(Take)
{
verify()
{
illogical('{You/he} can\'t carry {the dobj/him} around. ');
}
}
;
|
|
|
dobjFor(Take)
{
remap = nil
verify()
{
illogical('{You/he} can\'t carry {the dobj/him} around. ');
}
}
;
|
|
|
|
dobjFor(Push) maybeRemapTo(isOpen, Close, self)
;
|
The underlying code here is in fact:
|
|
|
|
|
|
dobjFor(Take)
{
remap = (gVerbName == 'take' ? [TravelViaAction, self] : nil)
}
;
Another situation when it's useful to use the underlying remap property directly is where you want different remappings depending on circumstances. For example you might want PUSH GATE to open the gate when it's closed, and close the gate when it's open. This is beyond the ability of maybeRemapTo, but quite possible with the underlying remap property:
|
dobjFor(Push)
{
remap = (isOpen ? [CloseAction, self] : [OpenAction, self] );
}
;
|
Getting Started in TADS 3
[Main]
[Previous] [Next]