The TADS 2 method (IIRC):
- The library contains a "Thing" class, which has action routines for all system verbs.
- It also contains a class "Container", derived from Thing, which has the "open", "close", "look in", etc. routines replaced. There are similar classes corresponding to supporters, clothing, and so on.
- An action routine can call the corresponding action routine in the parent class.
So you could have something like:
MetalThing is a subclass of Thing. IronThing is a subclass of MetalThing.
In IronThing, doTake() is
{
if (magnetic_field.is_on)
"It's solidly stuck to the floor!";
else
inherited.doTake();
}
In MetalThing, doTake() is
{
if (this.is_hot)
"You try to, but it's too hot.";
else
inherited.toTake();
}
And Thing.doTake() checks the player's capacity, and, if all tests pass, moves the object to the player's inventory and prints appropriate output.
The Inform method:
- For each verb, there is a ____Sub routine that does the typical work.
- An object may have one or more "before" routines.
- Whenever the parser tries to run an action, it will call the direct object's before routines in sequence.
- Each one may return true, to indicate that it has handled the action, or false, to indicate that it has not.
- The parser will continue to run the before routines until one returns true, or it runs out. If it runs out, it calls the ____Sub routine.
The important thing is that both methods have a way of passing the buck, if they can't immediately process it, and passing in such a way will always bottom out. Also, none of those commands are special; inherited, rtrue, and rfalse are also ordinary variables / commands.