YATCO - Yet Another Tabbed Chat Option. This time it blinks

Share your scripts and packages with other Mudlet users.
Yetzederixx
Posts: 186
Joined: Sun Nov 14, 2010 5:57 am

Re: YATCO - Yet Another Tabbed Chat Option. This time it blinks

Post by Yetzederixx »

I incorporated your script and it works excellent, I solved the problem of word wrap by making sure the copy() fn gets absolutely everything, this way you need not mess with the prompt thing. For example:

Code: Select all

Pattern: ^You say .*'.*'$
Will capture:

Code: Select all

say this is a really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, long line.

(Copied from miniconsole)
You say (Elvish) 'this is a really, really, really, really, really, really, really, 
really, really, really, really, really, really, really, really, really, really, really, 
long line.'
Image

Iocun
Posts: 174
Joined: Wed Dec 02, 2009 1:45 am

Re: YATCO - Yet Another Tabbed Chat Option. This time it blinks

Post by Iocun »

Yetzederixx wrote:

Code: Select all

Pattern: ^You say .*'.*'$
(This won't really capture your first example, but I'm sure this was simply a mistake of forgetting the quotation marks there.)
Anways, just a hint of making regex patterns slightly more efficient: It isn't normally a problem in Mudlet, since it will still match very fast, but as a general principle, I try to avoid using more than a single .* in a pattern, since it can slow down regex matching quite a bit.

Consider how the computer will do the matching if it gets the second line of your example:

Code: Select all

You say (Elvish) 'this is a really, really, really, really, really, really, really,
really, really, really, really, really, really, really, really, really, really, really,
long line.'
It will first attempt to match "^You say ", which matches fine on the received "You say", ok, no problem. Next comes the first ".*" of the pattern. This will match anything and by default, it will match as -much- as possible. So the first .* will match the whole rest of 'this is a really, really [...] long line' AT FIRST. Then it will proceed to try to match the '.*'$ of your pattern. The ' doesn't match however, since we already used up the whole received line in the first ".*". So the regex parser realizes that it doesn't match like this and BACKTRACKS, meaning that it will first remove the last character from the initial .* match and and again try to make the rest match the rest of your pattern. Again, this fails, and the parser again backtracks one step. This continues over and over again, until it has finally backtracked to making the first .* match only (Elvish) , after which the rest will match just fine.

You see, this involves a lot of steps that could have been avoided by simply making the pattern:
^You say [^']*'.*'$
(I.e. we replaced the .* by a [^']* meaning that instead of "match anything" it is now a "match anything except single quotation marks/apostrophs"). In that case, the pattern will never assign the whole rest of the line to that first wildcard, but realize immediately that the [^']* should only match until before the first single quote. This makes is no longer necessary to backtrack all the way, and speeds up matching a lot.

As a general principle, having several wildcards that can match a huge variety of things in the same pattern can slow down things, ESPECIALLY if those wildcards appear early in the pattern. Especially starting a pattern with a .* or .+ very often results in a lot of backtracking and so I'd avoid it whenever possible.
Unless the pattern is, say, just: ^.*$
In that case, it's no problem and there will never be any backtracking involved, since the pattern will match any line just fine, no matter of how it ends. (I guess it might be slightly more efficient to just use an empty pattern for "match-anything" though. But I'm not that regex-savvy to say that for sure.)

P.S. Er, sorry for the long derail. I got a bit carried away there...

Yetzederixx
Posts: 186
Joined: Sun Nov 14, 2010 5:57 am

Re: YATCO - Yet Another Tabbed Chat Option. This time it blinks

Post by Yetzederixx »

I used the .* because I didn't want to try and compile a list of languages to use in an or wildcard which may or maynot even be used, but I'll definitely look into your solution though as I knew that my use of the double .* wasn't "proper" but didn't know how to fix it on the quick.

syrik
Posts: 90
Joined: Sat Jun 26, 2010 9:57 pm

Re: YATCO - Yet Another Tabbed Chat Option. This time it blinks

Post by syrik »

I've been using this for a while, and was wondering how I could space the lines between globals?
For example:
Bob narrates 'hello'

Sam narrates 'hey'

That would be spaced, but this wouldn't be because it is the same line:

Bob narrates '<insert long lint of
text here>'

Sam narrates 'hey'
would it be something easy?

Yetzederixx
Posts: 186
Joined: Sun Nov 14, 2010 5:57 am

Re: YATCO - Yet Another Tabbed Chat Option. This time it blinks

Post by Yetzederixx »

You have to find a way to edit the captured string and add a \n to the end of it, how that's done with the copy/append functions is beyond me though.

User avatar
Vadi
Posts: 5048
Joined: Sat Mar 14, 2009 3:13 pm

Re: YATCO - Yet Another Tabbed Chat Option. This time it blinks

Post by Vadi »

Just echo(mywindow, "\n")

Damodred
Posts: 11
Joined: Tue Dec 28, 2010 7:48 am

Re: YATCO - Yet Another Tabbed Chat Option. This time it blinks

Post by Damodred »

Does this work for Achaea yet?

delfador
Posts: 7
Joined: Tue Jan 04, 2011 11:25 am

Re: YATCO - Yet Another Tabbed Chat Option. This time it blinks

Post by delfador »

yay ! i started on mudlet just 2day and already got this tabbed chat working flawless in achaea :D :D...the blink feature is really awesum ..thanks

Yetzederixx
Posts: 186
Joined: Sun Nov 14, 2010 5:57 am

Re: YATCO - Yet Another Tabbed Chat Option. This time it blinks

Post by Yetzederixx »

^You say(?: \(\w+\))? '.*'$

is a much better pattern for languaged says like you see in my above example btw.

steve
Posts: 14
Joined: Sun Oct 17, 2010 9:01 pm

Re: YATCO - Yet Another Tabbed Chat Option. This time it bli

Post by steve »

Love this package. Hadrian tossed it my way (wotmud), and it works great. One thing.. I don't want it to blink, and I'm not sure how to remove the blinking without screwing everything up.

Post Reply