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.
 Entire forum ➜ MUSHclient ➜ Suggestions ➜ The Plugin "onPluginLineReceived" callback change

The Plugin "onPluginLineReceived" callback change

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


Posted by Nexes   (65 posts)  Bio
Date Sun 30 Apr 2006 02:34 AM (UTC)

Amended on Sun 30 Apr 2006 02:40 AM (UTC) by Nexes

Message
Could you make it so it behaves more like OnPluginPacketRecieved? *hope*

Ie: if you return something, it changes it to the string/whatever you returned AND you can see ansicodes in the line?

Pretty please?
Top

Posted by Nick Gammon   Australia  (23,121 posts)  Bio   Forum Administrator
Date Reply #1 on Mon 01 May 2006 06:16 AM (UTC)
Message
Can you explain that in more detail please? What do you mean by "see ansicodes in the line"? If the replacement data has ANSI codes in it, they should be processed normally.

- Nick Gammon

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

Posted by Nexes   (65 posts)  Bio
Date Reply #2 on Wed 03 May 2006 02:56 AM (UTC)
Message
Oh, I meant the ansi color codes. You can't see nor modify them in the onLIneReceived variant. Where as in the onPacketRecieved you get everything, can change everything, and it is reflected in the output MUSHclient shows.

The thing is, I currently used this to change how my prompt looks and do custom coloring to it, but sometimes the prompt comes seperated in two different packets <_<.

Problematic it is.
Top

Posted by Nick Gammon   Australia  (23,121 posts)  Bio   Forum Administrator
Date Reply #3 on Wed 03 May 2006 05:54 AM (UTC)
Message
Oh, I see. I didn't read the subject as closely as I should have.

The problem with that suggestion is that by the time an entire line arrives, the ANSI codes have already been processed, MXP codes processed, telnet sequences processed and so on.

All I can suggest in your case is to "batch up" your packets in the script until a newline (spanning multiple packets if necessary), and then "release" the whole line to MUSHclient, changing colours as required.

For multiple packets per line, the initial one could simply return nothing, and the one which finally has the newline can return all the previous packets concatenated together.

- Nick Gammon

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

Posted by Nexes   (65 posts)  Bio
Date Reply #4 on Wed 03 May 2006 01:32 PM (UTC)
Message
Ahh, thats unfortunate.

How would your idea work the with option to convert IAC EOR/GA turned on? The IAC EOR/GA would still be in the packet or would it already be a new line there?
Top

Posted by Shadowfyr   USA  (1,788 posts)  Bio
Date Reply #5 on Wed 03 May 2006 07:37 PM (UTC)

Amended on Wed 03 May 2006 07:40 PM (UTC) by Shadowfyr

Message
It would be the raw packet data, so you would have to watch for the sequence yourself in the code, insert the new line and pass the result to Mushclient. Its kind of complicated. Initially when the idea for capturing lines was suggested I think most of us where thinking:

1. recieve packet.
2. Is this a complete line? If no, then 1.
3. pass line in raw form to script, if trapping functions are available.
4. process line or the result returned by the script.

Instead we got:

1. recieve packet.
2. Process packet.
3. Is this a complete line? If no, then 1.
4. Pass stripped text to script, if trapping.
5. Display if no trapping happened or, if trapped, the script indicates that it should be displayed.

So, after some teeth nashing and barely held back bad language Nick added the packet processing. lol I still think its not the most logical series of steps, since it only really acts like a more complex version of "omit from output", but... we ain't in control of this beasts development. ;)
Top

Posted by Nick Gammon   Australia  (23,121 posts)  Bio   Forum Administrator
Date Reply #6 on Wed 03 May 2006 07:56 PM (UTC)
Message
Quote:

How would your idea work the with option to convert IAC EOR/GA turned on?


First, this post shows a plugin that assembles lines from packets, this may help in writing the plugin:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=5020

Second, to answer your question, a simple regexp or "find-and-replace" could do what MUSHclient does itself, except in the (probably very rare) case of the IAC EOR being split between two packets.

eg. In Lua:


packet = string.gsub (packet, "\255\239", "\n") -- convert IAC/EOR to newline

packet = string.gsub (packet, "\255\249", "\n") -- convert IAC/GA to newline


Quote:

I think most of us where thinking:

1. recieve packet.
2. Is this a complete line? If no, then 1.


Shadowfyr, the problem with your suggestion, which the very early version of MUSHclient did, is that one of the first thing that arrives from most MUDs is something like this:


Enter your character's name, or type new:


Note the absence of the newline. Your suggestion would keep that in the "pending" box (because no newline had arrived), the player would not see it, he would not enter his name, and he would be unable to play.

- Nick Gammon

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

Posted by Nexes   (65 posts)  Bio
Date Reply #7 on Wed 03 May 2006 09:28 PM (UTC)
Message
Actually I was asking if the IAC GA/EOR would still be in the packet when I got it, meaning that it wasn't processed by MUSHclient already and switched to a newline. Im guessing it isn't though, heh.

Also, how would you suggest I avoid the problem you mentioned about something staying in pending forever? Turn the trapping on later after Im sure that Im connected? Ooor...hmm...?
Top

Posted by Nick Gammon   Australia  (23,121 posts)  Bio   Forum Administrator
Date Reply #8 on Wed 03 May 2006 10:26 PM (UTC)
Message
My reply was intended to imply that yes, it would still be there. MUSHclient maintains a "state machine" for incoming data, so it would correctly handle things like IAC/EOR spanning multiple packets. Thus, its handling of that is done after packet handling. For that matter, technically two IACs in a row should be converted to a single IAC and not treated specially, so strictly speaking: IAC IAC EOR is *not* the end of a line. This probably would not affect you in practice, but I am making you aware of the subtleties of trying to do things at the packet level.

As for the second problem, yes that is what I would do. Once you have connected and entered your name and password I would set a variable that the plugin could test. Once that variable is set you could start doing your own packet management.

Or, do something simple like having a regexp that detects a string that occurs once login has completed (like, "Welcome to Blah MUD"), and have that set the flag.

- 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.


28,569 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

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