Action that takes a direction?

I’d like to create an action that takes a direction/exit. For example, “cast north with frog legs”. I want to make sure to include directions that don’t currently have a an exit as well (north, when there’s no door to the north, etc).

I’m pretty new to TADS, and this one has me stumped. I found the source for the built-in actions, but that only got me as far as knowing how to handle the parsed directions, not how to get the parser to expect directions.

Any pointers on where I should read next?

My T3 is extremely rusty. (I’m assuming, also, that you’re using TADS 3, not tads3Lite.) But since nobody else has answered…

The first thing you need to know is that defining new actions is discussed in the Technical Manual, in the article “How to Create Verbs.” The second thing is that the vocabulary words for directions (‘north’ and so on) are attached to DefaultWall objects. Every room you create has four default walls – north, east, south, and west – unless you remove them.

Here’s a code template to get you started. You’ll want to refine this in various ways.

[code]DefineTIAction(CastDir);

VerbRule (CastDir)
‘cast’ singleDobj (‘to’ | ‘toward’ | ) singleIobj
: CastDirAction
verbPhrase = ‘cast/casting (what) (to what)’
;

modify Thing
dobjFor(CastDir) {
preCond = [objHeld]
action() {
moveInto (me.getOutermostRoom());
"You toss {the dobj/him} off toward {the iobj/him}. ";
}
}
;[/code]

The third thing you need to know is that ‘toss’ and ‘throw’ are already defined, and trigger the ThrowAt and ThrowTo actions. If you want to use them as synonyms for ‘cast’, you’ll need to modify the VerbRules for those actions.

I hope that’s enough to get you started!

You may find it helpful to take the existing ThrowDirAction as a model. Its VerbRule is defined as:

VerbRule(ThrowDir)
    ('throw' | 'toss') dobjList ('to' ('the' | ) | ) singleDir
    : ThrowDirAction
    verbPhrase = ('throw/throwing (what) ' + dirMatch.dir.name)
;

The action itself is defined as:

DefineTAction(ThrowDir)
    /* get the direction of the throwing (as a Direction object) */
    getDirection() { return dirMatch.dir; }
;

This allows you to use the expression gAction.getDirection() to get at the direction matched by the command.

Finally, the action-handling on Thing for ThrowDir is defined as:

    /* -------------------------------------------------------------------- */
    /*
     *   "Throw <direction>".  By default, we simply reject this and
     *   explain that the command to use is THROW AT.  With one exception:
     *   we treat THROW <down> as equivalent to THROW AT FLOOR, and use the
     *   default library message for that command instead.  
     */
    dobjFor(ThrowDir)
    {
        verify()
        {
            if (gAction.getDirection() == downDirection)
                illogicalAlready(&shouldNotThrowAtFloorMsg);
        }
        action()
        {
            /* 
             *   explain that we should use THROW AT (or DROP, in the case
             *   of THROW DOWN) 
             */
            reportFailure(gAction.getDirection() == downDirection
                          ? &shouldNotThrowAtFloorMsg
                          : &dontThrowDirMsg);
        }
    }

By using this as a model you should be able to do what you want.