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 ➜ Capturing same thing more than once in a single line.

Capturing same thing more than once in a single line.

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


Pages: 1  2 

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #15 on Fri 26 Nov 2004 06:06 AM (UTC)
Message
The replace thing wasnt in any seriousness, I know the design problems (especially considering it wouldnt get to Lua until after it matched, which means after it was displayed, which well, yeah, weve been over this).

As for color, I'd just as soon have it be ANSI sequences. And MXP, and everything.
If someone is going to be screwing around with low level stuff, they should be able to take care of colors/MXP/whatever.
Just like in assembly, or C, or whatever, as opposed to something higher (VBscript), yes, you MIGHT have overflows, or whatever, but since youre coding at a lower level, thats to be expected, and youre expected to be able to take care of that.

As for the line triggering problem, its the same thing if youre omitting. Yes, you might be inserting something, or changing something, but we do the same thing with things being omitted.

And make it a plugin callback, I think that would be the most useful. Because you'd shield 'normal' users from it, and wouldnt have to rewrite anything that already exists. Just give the plugin the line, and have it return the new line (both including color/mxp/etc, just an assembly of packets, let the plugin writer deal with everything, to give him the most flexibility).

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Poromenos   Greece  (1,037 posts)  Bio
Date Reply #16 on Fri 26 Nov 2004 08:02 PM (UTC)
Message
Quote:

Now if I wait for the newline, you don't get to see "Enter your name ...". If I don't then the text is already on the screen, it is a bit late to start doing find-and-replace on it.

What happens if the user wants to omit "Enter your name*" from output? Doesn't this still happen?

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #17 on Fri 26 Nov 2004 08:29 PM (UTC)
Message
Yes, when the newline eventually appears, *after* they have entered their name.

- Nick Gammon

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

Posted by Poromenos   Greece  (1,037 posts)  Bio
Date Reply #18 on Fri 26 Nov 2004 09:51 PM (UTC)
Message
So the problem exists already, it's not exclusive to the replacement function.

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #19 on Fri 26 Nov 2004 10:23 PM (UTC)
Message
Which is why I dont see it at a major problem. Yes, its going to sometimes be an awkward transition, for slow connections or prompts, or a few other situations. But we do the same with omitting.
Yes, it doesnt work quite like we'd like it to, but we cant control the servers, and it isnt a crippling problem.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #20 on Fri 26 Nov 2004 11:05 PM (UTC)
Message
Yes, the problem already exists, but what you are asking is for something to be retrospectively changed on the screen. At present all the "problem" is, is that trigger don't fire until a newline.


- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #21 on Sat 27 Nov 2004 02:28 AM (UTC)

Amended on Sat 27 Nov 2004 02:42 AM (UTC) by Nick Gammon

Message
Well, I think I have worked out a way of solving the "replace stuff in lines" problem. The major problem so far has been that in trigger matching, if you try to do fancy omitting from output in "send to script" any world.notes are also omitted, and if you wait until a trigger script (in the script file) executes, the original line has already been omitted.

I was reluctant to alter the way trigger calls worked, because that would break existing scripts. However with Lua, there is a way *grin*.

Lua allows optional arguments, so I have added a fourth argument to the trigger script (only available under Lua). This fourth argument is a table of all the style runs in the matching line, including the text colour, background colour, text itself, and the style type (eg. bold).

Now with a simple bit of scripting, you can replace one word with another. Here is an example:


function my_trigger (name, line, wildcards, styles)

  for _, v in pairs (styles) do
    
    ColourNote (RGBColourToName (v.textcolour), 
                RGBColourToName (v.backcolour), 
                (string.gsub (v.text, "will", "*WILL*")))  
  end

end



I think this is pretty self-explanatory. It echoes the existing line to the output window with ColourNote (translating colour numbers to colour names). This keeps existing colours. Then by doing a gsub (global substitution) it replaces the word "will" by "*WILL*".

Now of course, if "will" spans a colour boundary, then it won't match, but that sort of problem is the thing that was always going to be a problem with trying to replace words in coloured text. The next post will show how it looks:

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #22 on Sat 27 Nov 2004 02:28 AM (UTC)
Message

Hell
As if picked up by the scruff of your neck by a mighty hand, you find
yourself unceremoniously dumped at a strange gateway.  Here is the
place which *WILL* determine your fate.  Whether you *WILL* be sent back
to life as you once knew it, or proceed onto a far yet bleaker pathway.
The time has come for you to plead your case and await judgement for the
crimes that have been placed upon your head.  Speak wisely and choose
your words carefully, for your testimony *WILL* be written in the ledgers
of the Gods, and *WILL* determine the path you *WILL* ultimately travel.
Exits: none.
A mystical spring flows majestically from a glowing circle of blue.
A fountain of fresh blood flows in the corner.
A demon imp hovers nearby...drooling constantly with a fiendish grin.

<1000hp 100m 110mv> 
think I will go to sleep
You think 'I *WILL* go to sleep'

<1000hp 100m 110mv> 
<1000hp 100m 110mv> 

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #23 on Sat 27 Nov 2004 02:30 AM (UTC)

Amended on Sat 27 Nov 2004 02:31 AM (UTC) by Nick Gammon

Message
In the example above, I had a simple trigger that matched the word "will" (regular expression), omitted from output (so you didn't get two of them), and called the script shown above.

Notice how the colour of the original line is retained.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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,572 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.