SMM++ Manual Version 5.0

6 SMM++ Action System

6.1 Processing of the text received from the MUD

When a MUD sends its output/text to the client, it sends it in one or more packages without caring about the contents. This can cause some minor problems, when the client wants to process the recieved text, as it would process 'sequences' of characters, which could accidentially be broken up.

This problem is solved for ESC sequences as they are handeled by the SMM data processing as SMM just waits until the sequence is complete.

Problems may arise, if the user wants to process the text: e.g. for action triggers. Let me explain it in detail:

Normally you expect the text from the MUD comming line by line .

      You miss elite guard.
      Elite guard absolutely destroys you with his hit.
      ...(and so on in a fight)...
    
Now imagine, that you have an action on 'absolutely destroys you', which lets you flee, but you recieve the text in two packages, splited right after 'absolutely':
  1. If SMM would parse all received packages of text separately, the action wouldnt be triggered at all.
  2. On the other hande side one doesnt want to wait, until the next newline really comes. Sometimes (e.g. password input) they never come and sometimes you just dont wait so long (just having a little hangup/lag). E.g. if your trigger would have been 'Elite guard absolutely' you would be really angry, if the trigger just didnt trigger, because of a missing newline.

Therefor two things are done:

  1. After each received packet of data the line is parsed
  2. and after each newline the whole last line is parsed.
In the above case first
  • Elite guard absolutely
    and then
  • Elite guard absolutely destroys you with his hit.
would have been parsed Please keep this behaviour in mind, when you build your action triggers/substitutions/highlights/notouch lines! There is more to say about text processing. Read on, please:

6.2 Action Triggers

Actions are the only way to parse and change/remove/etc. text, which is coming from the mud. SMM++'s action system is much different from what you might be used to from tintin or SMM versions prior V5.0. So, please, read carefully and make sure that you understand what is going on, because it is a very powerful tool. You can have a look at the system scriptfiles. There you can find examples how to use it; e.g. automap. OK, now lets start,..

Defining actions in SMM++ is a two step process:

  1. You tell SMM++ how to parse the text.
  2. Tou tell SMM++ to start parsing and the priority.
This approach may seem odd at first glance, but isnt.

To tell SMM how to parse the text, you have to write a procedure (former alias, please have a look at proc command). This procedure has to take exactly one argument. Later (i.e. during running) this procedure will be invoked by SMM. Its argument is the line of text, which needs to be parsed. Within this procedure you can do as many comaparision as you want or what ever else you like to do.

Lets give an example. Its OK, if you dont understand all the commands; just read on and come back, if you have read the sections tcl commands and smm commands sections.

Example:
    # Each time Fred or Barney tell us something,
    #  we will tell them to shut up.

    # 1) The procedure we define has the name 'SUBF'.
    ::proc SUFB {line} {
      ::if {[string match "Fred tells you:*" $line]} {
        tell fred shut up!
        ::return 1
      }
      ::if {[string match "Barney tells you:*" $line]} {
        tell barney shut up!
        ::return 1
      }        
      ::return 0
    }

    # 2) Now put this procedure into the SMM++ action system
    #    The second argument '10' is the priority.
    ::smm::action::set SUFB 10

I hope, this example already hints, how powerful the new approach is. First of all, you only need to spend one action, which is doing two jobs. You even can do calcultions, string operations, or anything else here.

In the example above you can see three ::return statements. All actions have to return either 0 or 1. If 0 is returned, parsing is not stopped, If 1 is returned, parsing is stopped; this means that no further actions are invoked.

The priority has to be a real number. The list of actions is an ordered list: actions are listed decreasingly according their level. Action with the same level have no defined relativ order, which even can change during running.

6.3 Highlightning, Gaging, Substitutions...

There is no sepate highlightning/gaging/etc. system in SMM. You have to use the action system and call commands, which can change the last received line. You can delete, change or colorize the text or change the font of it. Please refer to the section Text Commands.
Selim Issever
<Mudding with SMM++|Contents|Commands: Tcl>