[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ General ➜ First project

First project

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by tobiassjosten   Sweden  (79 posts)  Bio
Date Sat 23 Apr 2005 10:37 PM (UTC)

Amended on Sun 24 Apr 2005 12:34 AM (UTC) by tobiassjosten

Message
Alright, I just decided that I will make a serious attempt at switching to MC from zMUD (after nine years of using that client). To learn the how MC works, what's better than to start a little project of my own? I chose to make a module for highlighting and validating channels.

The first problem I ran into was that I do not know in what order MC processes the triggers. It seems to sort them all in alphabetic order, so how can I tell what will react first and so? Also - will substitution (if supported by MC) disable further parsing of triggers with the same pattern? And can you match ANSI, using regexp?

The format of channels on the MUD i play (IRE - Imperian) looks like this:
(Channel): Crox says, "Looking to learn MUSHclient."
(Channel): You say, "Looking to learn MUSHclient."
<<Channel>>: Crox says, "Looking to learn MUSHclient."
<<Channel>>: You say, "Looking to learn MUSHclient."

Easy enough to highlight. The problem is that the Rapture engine (IRE-engine for all its MUDs) breaks the lines if they exceed 80 chars. I solved this in zMUD by enabling a class with a trigger that fired on everything, and colored it for me. In that class I also had a prompt-trigger, which closed the class. Quite effective (besides some zMUD-specific bugs). How can this be achieved in MUSHclient?

The validation I want for this module is to check if the line(s) is of a certain color. This can be configured, and will be used as a protection from illusions (I'm overly paranoid when it comes to that). When it's verified, I want the "(Channel):"-part in one specific color (defined by the channelname, located in an array or something) and the rest in plain white color.

Furthermore, if I wanted to make this into a module/script (set of triggers/aliases/variables/whatever), how should I go about doing that? I'm not all clear on what seperates triggers/aliases/variables/whatever from scripts. Is it that scripts are in external files, which are called from triggers and such? The thing is that I want to be able to share this module in just one file, a feature I've been missing with zMUD for nine years.

EDIT: Putting in what I have so far. Regexp looks -really- powerful, and not all too hard to learn.
<triggers>
  <trigger
   custom_colour="1"
   enabled="y"
   match="^(\(|\&lt;\&lt;)[[:alpha:]]*(\&gt;\&gt;|\))\: *"
   regexp="y"
   sequence="100"
  >
  </trigger>
</triggers>

Simplicity is Divine | http://nogfx.org/
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #1 on Sun 24 Apr 2005 05:42 AM (UTC)
Message
For substitutions (in the real sense of the word) you'll have to take a look at the plugin callbacks (search for "OnPluginPacketReceive". You can also use it to match ANSI (and have to) and thus can change colors and such.
And then the plugins continue on to triggers, so you can substitute, and then match the substitutions.
You can also use normal triggers to match, and then take a look at the ANSI codes once youre into the trigger and doing proccessing that way (with the style info).

As for trigger matching, it's in the sequence order (you can specify) default is 100, lower sequence gets evaluated first.
You can either stop the proccessing there, or keep going to further triggers, if you have 'keep evaluating' checked (so you can have multiple triggers match the same line, or you could have a lot of triggers match, and can stop them all from matching by making a new trigger with lower sequence, and having it NOT keep evaluating).

Scripts are scripts, they are in a scripting language (VBscript, Lua, PerlScript, JavaScript) while triggers/etc are properties of the world. The scripts interface with the world using the inbuilt script functions.
It's not like ZMud where you simply proccess a batch of 'scripts' to set up your environment everytime, instead, you set up world files (which are in XML, so you can go ahead and edit to get familiar with them) and then those aliases/triggers can call script subroutines, or can just proccess a script within them (send to script, instead of a script routine, makes whatever is in the 'send' box get sent to the script engine and get proccessed that way).

Mushclient also lets you (for sharing purposes) put collections of triggers/aliases/variables/etc into plugins (along with corresponding scripts, if you aren't using send_to_script exclusively) into one file, which can be loaded into a world, which will allow you to share your things quickly and easily (and with only one file).

Yes, regexps are extremely powerful and flexible and aren't too hard to learn. I do suggest you get used to the perl style (PCRE, perl compatable regular expression) (as opposed to POSIX regexps), because "\w" (or even [A-Za-z ]) is much easier to write/maintain than [[::alpha::]].

I think you'll find that you can do anything you'd like with mushclient (anything ZMud can do, and then some). Although it may have to be done with a little scripting/programming.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Nick Gammon   Australia  (23,046 posts)  Bio   Forum Administrator
Date Reply #2 on Sun 24 Apr 2005 06:57 AM (UTC)
Message
Do a bit of a search on this forum for something like "convert zmud trigger", and browse some of those posts. There have been a few examples in the past, including a fairly extensive conversion that I did a while ago (which I can't find right now).

Most of the rest of your questions were accurately answered by Flannel.

You can make triggers match on a colour (actually the colour of the first letter of the matching text), or if you want to go further have the trigger call a script and have the script "walk" the style runs for the matching line to see exactly what colours you got. This is particularly easy if you use Lua as the script interface.

Plugins are a great solutions for sharing, and you can also use "default" trigger sets, but I would use plugins these days for maximum flexibility.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by tobiassjosten   Sweden  (79 posts)  Bio
Date Reply #3 on Tue 26 Apr 2005 07:14 AM (UTC)

Amended on Tue 26 Apr 2005 07:58 AM (UTC) by tobiassjosten

Message
I've gotten it all to work pretty decent. The only problem I'm experiencing is with the omit-option. As I do the output with scripts, I don't want the original line there, so I omit it. But then even my output is omitted. Is this because the trigger fires on the output?

So far I've got:
<triggers>
  <trigger
   enabled="y"
   match="^(?P&lt;channel&gt;(\(|\&lt;\&lt;)\w+(\)|\&gt;\&gt;))\: (?P&lt;message&gt;.+)"
   match_text_colour="y"
   regexp="y"
   send_to="12"
   sequence="100"
   text_colour="11"
  >
  <send>EnableTrigger("chanCap", true)
AnsiNote (ANSI (35, 1, 30) .. "%&lt;channel&gt;" .. ANSI (37, 0, 40) ..
    ": %&lt;message&gt;")</send>
  </trigger>
</triggers>


Edit: Ofcourse it can't be. That trigger only fires on yellow text, and the output isn't yellow. How wierd.. Anyone know how to work around this?

Simplicity is Divine | http://nogfx.org/
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


14,137 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]