action - Make an action or display defined actions
action pattern ?commands?
An action consists of a pattern and a command. When mmucl recieves output from the mud it checks the pattern of each action to see if that pattern matches the mud's output. If it does then the commands associated with the pattern are executed. Note that the matching is case insensitive and that the patterns are regexp patterns. For info on regular expression look at the regexp documentation in your tcl distribution.
Action with two arguments will create an action with pattern as the pattern to be checked for and commands as the commands to be executed when the pattern is found. When mud output matches an action's pattern then the text matching each paranthesized expression of the pattern is substituted for @n in the commands associated with the pattern. n corresponds to the number of the match. Up to 9 matches are supported.
Action with no arguments will print out all the currently defined actions. Action with one argument will return all defined action matching the pattern the argument gives just like alias. In this case pattern should be a glob pattern.
action {([a-z]+) grins at ([a-z]+).} {echo
"That idiot @1 grinned at @2!!!"}
Mark grins at David. will cause "That idiot Mark grinned at David!!!"
to be written to the screen.
@0 is the entire match ie. Mark grins at David.
action m*
This prints out all the aliases that begin with m.
Action's are potentially a big security hole. Don't rule out the possibility that someone could slip some nasty code into text that an action is substituting. For example if you have an action {(.+) grins at you.} {writemud "kill @1"} it is possible that instead of a name someone could figure out how to put in a command, like [file delete "important file" ], that would be executed when the arguments to echo are evaluated. It's a bit of a pain, but if you wanted to you could modify mmucl to have a safe interpreter execute all user commands.