Hello,
I've seen other clients that do this, but I haven't been able to replicate this functionality in MUSHclient.
Basically what I'd like to see is a way to match on a line of text, and be able to parse crucial information out of that line of text and into variables, then substitute the old line of text with a new, shorter one, for example.
I've tried doing this by checking "omit from output", but calls to world.simulate() do nothing when this option is checked, at least as far as I can tell.
To keep colours, if you send to 'script (after omit)' it will save the line in a table called TriggerStyleRuns, which you can use like this to replicate the line:
for k, v in ipairs (TriggerStyleRuns) do
ColourTell (RGBColourToName (v.textcolour),
RGBColourToName (v.backcolour),
v.text)
end -- for
Note ("")
You can, anywhere within this, modify the line however you wish by adding a tell before it, modifying v.text in the tell for a certain section, or adding to the end by adding to the note.
Just noticed you said 'world.' so I'm guessing you're not using Lua. That's how I'd do it in Lua, not sure about your language.
I noticed that If I try to use two triggers to change two lines that are close together, a score display, for example, the first trigger works fine, but the second doesn't even execute, for some reason.
In the MUD I'm playing, the verbose score display is written in sentence format. Just to test, I tried setting up some substitution triggers for the first two lines. The first trigger works, getting variables with the current/max HP, guild points, quest points, achievement points etc, but the second line that's supposed to tell me my XP, guild level and rating shows up as normal, instead of being substituted.
I would be cautious about using Simulate, that was really intended for debugging. ColourNote, ColourTell etc. are the way to go for putting stuff back into the output window.
As for your trigger problems, triggers work pretty reliably. It is most likely that your matching is off. Try posting the example MUD output, and your exact triggers, see: http://mushclient.com/copying
Ok, here's the text that I'm trying to substitute. Just FYI, I'm using VBScript in the triggers.
"
You have 1919 (1919) hit points, 120 (349) guild points, 410 (679) quest points, 128 (1021) achievement points and 500 (500) social points.
Your current experience is 65690 and you are level 246 in Mrs. Widgery's Lodgers; your overall rating is 95476.
"
The XML for the triggers is:
<trigger
enabled="y"
group="score"
keep_evaluating="y"
match="You have * (*) hit points, * (*) guild points, * (*) quest points, * (*) achievement points and * (*) social points."
omit_from_output="y"
send_to="14"
sequence="1"
>
<send>world.tell "HP: %1/%2. GP: %3/%4. QP: %5/%6. AP: %7/%8." + vbcrlf</send>
</trigger>
<trigger
enabled="y"
group="score"
keep_evaluating="y"
match="Your current experience is * and you are level * in *; your overall rating is *."
omit_from_output="y"
send_to="14"
sequence="1"
>
<send>world.tell "XP: %1. LVL: %2 (%3). RT: %4." + vbcrlf</send>
</trigger>
If I turn both triggers on, the first line gets modified the way I want it, but the second line remains unchanged. Once I disable the first trigger, the second one works.
The more important point is that Tell is for partial lines, and Note is to have the client complete the line for you (in which case you don't need the vbcrlf).
Note only is that shorter and neater, I think earlier versions got a bit confused with the transitions from Note lines to MUD output, so it possibly didn't recognize the second line as MUD output, and therefore something to be triggered from.
I did that, and with both triggers enabled, got the following:
Matched trigger "You have * (*) hit points, * (*) guild points, * (*) quest points, * (*) achievement points and * (*) social points."
However, the second trigger didn't match, as if the first one was somehow preventing the second one from being matched on or executing.
When I disabled the first, I got this instead:
Matched trigger "Your current experience is * and you are level * in *; your overall rating is *."
Trigger matching is atomic on lines. There is no behaviour that, if one line matches, it somehow prevents future lines matching (unless, of course, the first match executes a script that disables triggers).
I am starting to wonder about your "lines". That is why I queried the use of world.Tell instead of world.Note.
Since my test worked, that confirms that your triggers are OK, and the client is OK. Now we have to wonder about the input data. ;_)
Can you please go the Edit menu and turn on Debug Packets? Then reproduce the problem. Turn Debug Packets off or the packet debug will get very large. In the resulting packet debug window, find the packet or packets that contain the problem lines, and post them here.
Aha. The line in question was indeed a bit unusual. :-)
See this:
oints..[4z<BR>Yo 6f 69 6e 74 73 2e 1b 5b 34 7a 3c 42 52 3e 59 6f
This MUD is not sending the normal newline character but instead sending <BR> - I presume it is using MXP or Pueblo.
You have found a bug in MUSHclient where, if it gets <BR> it indeed starts a new line, but marks the new line as a "note" line (the same type as the previous line), which stops the trigger matching, as you surmised.
That will be fixed in version 4.42, but meanwhile the small plugin below seems to fix it, at least for the packet I tested it on.
Copy between the lines, and paste into a text document called Convert_BR_to_newline.xml.
Then use the File menu -> Plugins to install that for this particular world. What it does is convert <BR> to actual \n characters, so then the trigger matching works.
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
name="Convert_BR_to_newline"
author="Nick Gammon"
id="a21640627ddd088ebb72980d"
language="Lua"
purpose="Converts <BR> to newlines when in MXP mode"
date_written="2009-06-27 12:40"
requires="3.67"
version="1.0"
>
</plugin>
<!-- Script -->
<script>
<![CDATA[
function OnPluginPacketReceived (s)
if GetInfo (104) or GetInfo (105) then -- MXP or Pueblo active
return (string.gsub (s, "<BR>", "\n"))
else
return s
end -- if
end -- OnPluginPacketReceived
]]>
</script>
</muclient>