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':
Therefor two things are done:
Defining actions in SMM++ is a two step process:
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 |
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.