Hmm. First off, triggers, timers and aliases are not part of the scripting as they tend to be in other clients. These things are inbuilt and handled differently. The reason they look like XML in the examples is because they are saved to your world file in that format *and*, in order to make posting and copying of them easier, Mushclient lets you 'copy' or 'paste' them to and from the editors in that format. This means you could open a world file with notepad, copy out a trigger, alias or timer and paste it into the list of a new world directly without changing anything. It also means you can paste one into the forum and someone else can directly copy and paste that into their own world.
Since world files and plugins are both entirely XML based, this also means that everything for a plugin, including the real scripts, can be placed on the forum and simply copied off, pasted into your favorite editor and saved as an XML file. All you have to do then is install the plugin. You could do the same with world files, except that the main script file is a seperate file for those, since it makes editing and reloading it easier. Plugins are supposed to be more or less already debugged and thus not something you edit a lot.
Anyway.. What you want to do is partly very easy, and partly frustrating. In the simplist terms you need a trigger that matches (I assume without an example):
^(You tell|.* tells you)\: .*
This is a regular expression, since a normal trigger can't match on more than one situation. The XML for it, if all you wanted was to change the color, would look something like:
<trigger
match="^(You tell|.* tells you)\: .*"
custom_colour="17"
enabled="y"
regexp="y"
other_text_colour="gold"
other_back_colour="black">
</trigger>
Again, this is just an easy copy-and-paste XML code. If it was actually done in script, it would look more like:
world.addtriggerex "telltrigger", "^(You tell|.* tells you)\: .*", "", 1057, -1, 0, "", "", 0, 100
world.settriggeroption "custom_colour", "17"
world.settriggeroption ""other_text_colour", "gold"
Needless to say that this would need to either be executed in the command window, in a script file or using the ctrl-I immediate mode input box. Unless you really are designing a script to change the trigger, you really don't want to mess with this. lol The XML is a lot easier and, even in scripting, there is now an import function that lets you import the XML, instead of using the 3 commands above.
Anyway. That would color it. Just one problem.. Currently triggers cannot 'replace' text, so your second need isn't directly possible. With a few changes you can sort of do it though.
<trigger
match="^(You tell .*|.* tells you)\: (.*)"
enabled="y"
sent_to="12"
regexp="y"
omit_from_output="y"
<send>telltemp = instr("%1", "tells")
telltemp2 = instr("%1", "tell")
if telltemp then
tellname = left("%1", telltemp - 1)
colourtell "gold", "black", tellname & " "
colourtell "gold", "black", "TELLS you: "
colournote "gold", "black", "%2"
else
tellname = right("%1", len("%1") - (telltemp2 + 4))
colourtell "gold", "black", "You TELL" & tellname & ": "
colournote "gold", "black", "%2"
end if</send>
</trigger>
Note: I haven't tested this code, so the 'left' and 'right' commands may not work as intended. They could be off by one character, making the name retrieved incorrect. Just adjust how much gets added or subtracted (the - 1 and + 4 bits) to fix it.
This would do what you intend, more or less. Changing text in a line is problematic at best, while simply coloring it is very simple, changing it basically requires that you have to redisplay the line manually through script commands. Omit_from_output tends to complicated matters, since while you can read the original lines from the output window, omit_from_output erases them *before* this information can be retrieved. Also, if your mud automatically line wraps tells on there end, the situation become about 50 times more complex. The one I play on does and I need four triggers to color stuff properly. Even then, it fails about 10% of the time when something unexpected happens, like someone on the staff dump ansi graphics on the screen before the trigger that ends the coloring is triggered. Good luck if yours is like this too. ;) |