Quote:
Why can't you just put the ATCP stuff in your main script file?
I think it uses the OnPacketReceived plugin callback, to process the raw data in the MUD input, and that only works in plugins.
Quote:
Will this slow me down any though having to pass the info all over the place?
MUSHclient is pretty fast. To reconfirm that I wrote the test below.
To pump test data through the client I used a test file I had from my benchmarks page, the file being:
http://www.gammon.com.au/mushclient/high.txt
This file contains 5,378 lines of MUD example output, including colour codes, so it has to do all the ANSI decoding as it processes it.
The test below generates 1,000 random triggers (matching on a 20-character string like "[McN`pNrCHzDXiHfxNwF"). These triggers will not match, thus forcing MUSHclient to evaluate 1,000 triggers per line, for 5,378 lines.
In addition I added the following trigger 10 times:
<triggers>
<trigger
enabled="y"
keep_evaluating="y"
match="a"
regexp="y"
send_to="12"
sequence="200"
>
<send>something = something + 1</send>
</trigger>
</triggers>
This matches 3,788 lines (because most lines have "a" in them). This does an addition using send-to-script. Thus for all of the 3,788 matching lines, it has to do 3,788 * 10 script calls (a total of 37,880 send-to-script).
The sequence number of 200 makes sure it is tested last, after the 1000 other triggers.
require "addxml"
-- make 1,000 random triggers
for i = 1, 1000 do
local match = ""
for k = 1, 20 do
match = match .. string.char (math.random (string.byte ("A"), string.byte ("z")))
end -- random word
addxml.trigger {
enabled = 'y',
sequence = '100',
match = match,
group = "test",
}
end -- for adding triggers
something = 0 -- for the addition test
-- timing test
tstart = os.time ()
-- simulate MUD input
for line in io.lines ("high.txt") do
Simulate (line .. "\n")
end
tend = os.time ()
print ("Time taken = ", os.difftime (tend , tstart))
So what is the result of all that?
So the whole thing took 8 seconds (which included loading the high.txt file from disk). Now if you divide 5,378 lines by 8 you get 672.
In other words, it was able to keep up with processing 672 lines per second processing 1,000 non-matching triggers, and 10 matching triggers in most lines.
Considering that a screenful of data is around 20 lines, I think the trigger matching, and scripting speed, easily would keep up with MUD output, even with a lot of script processing, and not slow down significantly.
I ran this test in the Immediate window (with the file high.txt in the same directory as MUSHclient).
Be warned if you run it multiple times you will get longer figures, as it will add 1000 random triggers every time, and thus trigger processing will take longer. |