Syntax: #action {pattern} {commands to be done} [{priority}] [group_name]
This command describes the action to be taken by the JMC, when text mathing the pattern arrive from the MUD. The variable's %0-9 are substituted from the input string, and can be used in the command(s) side of the command.
All actions are stored in a list. Any string arriving from the MUD is checked against the actions list to see if any of them match. If you have any important actions and want them to be checked first, simple set a greater priority for them. Zero is most important (highest) priority, 9 is the least important (lowest) priority.
If the pattern string starts with a ^, only the beginning of the line will be searched. This is particularly useful so that triggers don't get activated by the wrong text. For example, if you have a trigger that makes you eat a piece of bread when the message "You are hungry." arrives, someone might trigger that by actually shouting that out - "Someone shouts 'You are hungry.'". This would result in the trigger being activated, since the text matches. If you add the '^' character to the start of the trigger, then the shouted command will not match, because it doesn't start with "You are hungry.".
If the #action command is used with no arguments, all defined actions are listed.
If #action is used with only one argument, all defined actions that match this argument will be displayed. The * wildcard character can be used here.
Regular expressions: If first parameter of an #action command start by ‘/’ symbol and ends by ‘/’ symbol this string will be used as a regular expression. Regular expressions is a powerful method if description strings masks. If you are not familiar with it – read its format before. Every part of regular expression, limited by ‘(‘ ‘)’ symbols will be placed into %0-%9 variables while executing regular expression. Regular expression always creates with “global” flag. Here is regular expressions format.
By default action creates in “default” group.
Examples:
#action {You are hungry.} {eat bread} {2}
When you are getting hungry, you will automatically try to eat some bread.
#action {%0 arrives from the %1} {kill %0} {0} {pkill}
When anyone arrives in the room, you will attack him. NOTE: if "a hairy ogre" should enter the room, "kill a hairy ogre" will be sent to the MUD. The %0 in this case substitutes for everything before "arrives from the". This action creates into group named “pkill”.
#action
Show all defined actions:
{The momentum of your kick}={sta} @ {5}
{You try to bash}={sta} @ {5}
{are hungry}={get $food $chest;eat $food} @ {5}
{are thirsty}={drink water} @ {5}
{crashes into you}={sta} @ {5}
{disarms your weapon}={get axe} @ {5}
#action *you*
Show all defined actions containing "you":
{The momentum of your kick}={sta} @ {5}
{You try to bash}={sta} @ {5}
{crashes into you}={sta} @ {5}
{disarms your weapon}={get axe} @ {5}
You can have JMC ignore the actions if you type '#ignore'. Turn the ignoring off by typing '#ignore' again.
You can see the command that JMC will execute when an action is triggered by using the #echo command. This feature can be disabled by typing '#echo' again.
To remove an action use the #unaction command.
See also: JMC commands groups #group #unaction