Modifying actions

In a Forum Thread
You find yourself inside a forum thread. How exciting!
Cab is here.

look at cab
Cab is a TADS 3 newbie, although very comfortable with programming in general.

greet cab
“Hello!” he replies. “I have some questions on action customisation.”

ask cab about questions
Alright, I have spent the last few days reading through TADS documentation and trying out things. I have some questions about actions:

  • How can I remap actions under certain conditions? Say I have a sword, and I can attack something with the sword. Now there is a completely different command, cut, that I want to remap to ‘attack dobj with iobj’, but only if iobj is the sword. So if I cut paper with scissors, the cut action would execute, but if I cut with the sword, the attak action would trigger.
  • I know it is possible to extend and modify classes with the modify keyword. When it comes to actions, what is the property called that holds the grammar string? Is there another mechanism to add or change action aliases? For instance, say I want ‘ex’ and ‘exa’ to work like ‘x’ for examine.
  • Is there in-game debugger commands to list all actions that can be applied to an object?
  • Can I remove an action from the game completely, without modifying the library itself?

Thanks for any input!

-Cab

For some purposes, the maybeRemapTo macro (you can search for it in “Learning TADS 3”) can be used for conditional remapping. But you don’t need it here, because (if I understand you correctly) you always want to remap CutWith to AttackWith when gIobj is the sword.

You could use the replaceAction macro in the action() block of iobj(CutWith) in the sword object. But actually, that would be overkill. All you need to do is use the asIobjFor macro in the sword object – something like this (I’m working from memory here, so it’s untested):

iobjFor(CutWith) asIobjFor(AttackWith)

The replace keyword should work for that. Look up the original grammar in en_us.t. There you’ll find:

VerbRule(Examine) ('examine' | 'inspect' | 'x' | 'look' 'at' | 'l' 'at' | 'look' | 'l') dobjList : ExamineAction verbPhrase = 'examine/examining (what)' ;
You can do this in your code:

replace VerbRule(Examine) ('examine' | 'inspect' | 'x' | 'ex' | 'scrutinize' | 'look' 'at' | 'l' 'at' | 'look' | 'l') dobjList : ExamineAction verbPhrase = 'examine/examining (what)' ;

I don’t know of one. In this case, the Library Reference Manual is your friend. You’ll have to dig down through the entire class list for the object. If it’s simply a Thing, under the Summary of Methods on the page for the Thing class in the LRM you’ll find dobjFor(AskAbout), dobjFor(AskFor), and so on and on and on. Now, by default most of these won’t do anything in the model world. The list of actions that cause the library to actually do something by default is far shorter – you know, examine, take, drop, put in, and so forth.

Hmm. You might try this:

replace VerbRule(Examine) '' : ExamineAction verbPhrase = 'examine/examining (what)' ;
The action still exists, which means other actions could remap to it (which might in fact be useful), but it now has no grammar, so the player can’t use the command.

Thank you!

Exactly what I was looking for!