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, confirm your email, resolve issues, 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.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ new to scripting

new to scripting

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


Pages: 1  2 

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #15 on Mon 05 Apr 2004 10:02 PM (UTC)
Message
Quote:

Nick, have you ever considered implementing an easy scripting system similar (or just support the "Z" scripting) as the "Z" client? It's very useful, and a lot of dumb people like myself would really appreciate it.


I thought the existing scripting was reasonably simple, and at least you have a choice of languages (Jscript, VBscript, Perlscript etc.).

The "send to script" option in triggers etc. lets you do one-line scripts easily enough, eg. to turn on a trigger group.

Quote:

I am aware of that exclusion option, however from the standpoint of coloring lines or words, Mushclient has a serious flaw. It colors *everything* it matched and ignores the exclusion.


The regexp processing is really a separate module (PCRE) which MUSHclient just calls. It then gets back a list of the matching parts of the line which becomes the wildcards, and the entire matching expression, which is the part that is coloured. By not "reinventing the wheel" for regexp processing it is, at least, pretty reliable.

I didn't closesly look at what happens with colouring parts of lines with exclusions, but could believe that the exclusion part forms part of the "matching expression".

eg. if you want to match on:

dog NOT FOLLOWED BY cat

then "dog fish" matches the expression, and "dog fish" is the *matching text* (not just dog).




- Nick Gammon

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

Posted by Shadowfyr   USA  (1,791 posts)  Bio
Date Reply #16 on Tue 06 Apr 2004 01:00 AM (UTC)
Message
True.. The problem here is that the user may intended:

Find "cats and dogs", but color "dogs" NOT "cats and".

It is a matter of interpretation. On one hand, yes you want it to match the entire line, color it *and* return specific wildcards. On the other hand, there is nothing stopping you from returning the wildcards in a second trigger and specifically using the exclusions to color it like above, if you had the option to actually tell it to use only the wildcards as the 'text' to be colored. So you can very precisely match the line and word to be colored, but *only* color the one word you want.

I am not sure how complicated that would be, but it would avoid the insanity that arises when all you want is to color one stupid word on a known line, but not the entire line or every instance of the word, even in other lines. The only way to do it now is to omit from output and unless you are 100% sure of what the colors are supposed to be, you can't really do it without jumping through hoops.

Of course... It did occur to me that you might be able to match the line in an earlier sequenced trigger, read the line style, then omit it in a second later trigger and finally output the changed line. I haven't tried it though. In theory... The omition shouldn't happen until 'after' the first trigger finishes, so the line should still be there and intact when reading the original, then be removed only after the second trigger hits. If so, then it solves most problems, though it isn't exactly what I would call elligant.
Top

Posted by Ked   Russia  (524 posts)  Bio
Date Reply #17 on Tue 06 Apr 2004 07:43 AM (UTC)

Amended on Tue 06 Apr 2004 07:45 AM (UTC) by Ked

Message
I still don't understand the need for reading the styles and replacing the line with custom text, maybe I am missing something. Why not just use triggers without any "loops" instead?


<triggers>
  <trigger
   enabled="y"
   keep_evaluating="y"
   match="cats and dogs"
   name="cats_and_dogs"
   regexp="y"
   send_to="12"
   sequence="10"
  >
  <send>EnableTrigger &quot;colour_dogs&quot;, 1</send>
  </trigger>
  <trigger
   custom_colour="14"
   enabled="n"
   match="\bdogs\b"
   name="colour_dogs"
   regexp="y"
   send_to="12"
   sequence="11"
  >
  <send>EnableTrigger &quot;colour_dogs&quot;, 0</send>
  </trigger>

</triggers>


The output would be:

cats and dogs, went for a walk
(cats and dogs) went for a walk
fishes and dogs are swimming in the pool

You could obviously make the first trigger in the sequence as complicated as you wanted to, and make as many secondary triggers as you like. This is much simpler than parsing styles.
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #18 on Tue 06 Apr 2004 07:45 AM (UTC)

Amended on Tue 06 Apr 2004 07:46 AM (UTC) by Flannel

Message
you could also do the same thing weve gotten used to doing for multiline triggers.

Have one trigger which matches on the whole line, which turns on a second trigger (which only matches on the word) and then colors it, turns itself off. The only complications one would run into is if the word is multiple lines on that line.

I suppose you could get around that by turning off repeat on same line (if you wanted only the first) or if youd prefer one of the latter ones, write a small script, or a second one-word trigger (and have trigger A(full line) turn on trigger B(one word, first word) which turns on trigger c (one word, and color) and then they all turn off save A.

Yes, its not quite streamlined, but it does work.

Still have the problem of replacing words, but thats a whole other issue entirely, it just continues coming up with the omit from output/resend new text stuff.

edit: seems like Ked and I were barking up the same tree (no pun intended) at the same time.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Ked   Russia  (524 posts)  Bio
Date Reply #19 on Tue 06 Apr 2004 08:51 AM (UTC)
Message
Ah, I see - completely forgot about that "replace a single word in a line" issue. Maybe because I never needed to do that :) How about a new callback - World.Substitute? That could be called only while a trigger is being processed and would pass back to the client a number of the trigger's wildcard along with the text to replace the contents of that wildcard in the line and the colour the new text should be displayed in:


<triggers>
  <trigger
   enabled="y"
   keep_evaluating="y"
   match="cats and (dogs)"
   name="cats_and_dogs"
   regexp="y"
   send_to="12"
   sequence="10"
  >
  <send>Substitute 1, "lions", "red"</send>
</triggers>


Output: cats and lions

This would mean that any style processing would be done by the client itself. Since I don't know how exactly Mushclient parses output through triggers and what information it has access to at any given point of time while processing a trigger, I have no idea if this is doable at all.

P.S. Yep, that happens to me alot lately :P
Top

Posted by Shadowfyr   USA  (1,791 posts)  Bio
Date Reply #20 on Tue 06 Apr 2004 07:29 PM (UTC)
Message
Well Ked.. If you do want it to match say the first and third instance of a word in the same line, but not the second? Point is, your can kind of get around the coloring issue, but doing so requires a rediculous hack job, tricks that only work in specific cases or complicated scripting to bypass the built in coloring features. I hate hacks when the only reason you need them is because the existing feature doesn't work the way you expect. Same goes for word substitution, assuming the two trigger thing I suggested works, you still have to jump through hoops to make it happen, despite the fact that any feature that would let you tell it, "make changes effect wildcards only", would solve both problems. In theory. Yes, there is bound to be a little bit of extra processing to make it work right if/when you used that option, but it would work. Best we can claim of other sultions is 'they work, sometimes...'

The option would always both *replace* and *color*. So, if the send field is blank, you replace with the original text, if not, you replace it with what it in that field. Anything replaced will bump the rest of the line (and its styles) to the right, but the word inserted will either inherit the style at the point the match happened or gain a new style from the color settings. The only major issue is being able to fine down the coloring to a specific wildcard(s). I doubt people are going to stop screaming about this Nick.

The methods needed to 'fix' the issue are too complicated, can't be done without those complicated methods and don't always work as expected. All of which are turn offs for anyone that did use such things in another client, but are trying to make the switch to this one. Its a bit of a turn off even for me, and I am good enough to think my way around most problems.
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.


61,082 views.

This is page 2, subject is 2 pages long:  [Previous page]  1  2 

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

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