scroll back while displaying recent text

Posted by LupusFatalis on Thu 16 Apr 2009 11:16 PM — 36 posts, 130,928 views.

#0
Alright. Now, I'm not sure if there is a setting for this or whether it is something I will need to program.

Basically, what I want to happen is have the most recent lines (perhaps 10) still displayed at the bottom whenever I scroll back. This way I'm able to react to current events while looking back in time.
Australia Forum Administrator #1
A quick way is to go to the Window menu -> New Window.

This opens a new output window (and a new command window) for the same world, which displays the same stuff as the main one. However one window can be paused while you scrollback, and the other one can scroll. So with a bit of resizing and moving you can achieve what you want.

A more sophisticated approach might be to write a plugin that opens a small miniwindow at the bottom of the main window (resizing it to make room). This small window could then show the scrolling text. This is a bit more work, I don't think anyone has done that yet.
#2
Thanks Nick, I'm going to give that a try. I'll post my results when I get around to working on it.

I got a quick question on something else that I'm sure is just me being dumb... You see the mud has a prompt *sometimes* ... that is just "> "

So whenever it comes into play it makes all my triggers mess up. I was trying to figure out how to make a primary trigger to simply remove that text from the start of any line before the line is evaluated by any other triggers, but I can't.
Netherlands #3
You most likely want to select the 'Convert IAC EOR/GA to newline' option in the Output screen of your configuration. A good bet is that your prompts aren't terminated with a newline, which causes this issue of yours.
#4
That Convert IAC EOR/GA to newline doesn't seem to do anything. I guess I'll leave it on, not sure if it can hurt.

If it helps... I can solve it by making a second trigger for every trigger I have... that is a duplicate in every way except that the pattern starts with "^\> "

This just seems like a really cumbersome way of dealing with the issue. I'm not sure it will work later when I start doing some of the more complicated triggers.
Australia Forum Administrator #5
See http://mushclient.com/faq point 11.
#6
Nick, I read through that stuff. Eventually I found that LUA plugin you wrote, works beautifully... Haven't a clue about the language so I don't want to touch it. But it works now.

http://mushclient.com/forum/?id=7430

Of course now I have this funky little line with nothing but "> " on it, on occasion. But its a small price to pay for my sanity!

Thanks man!
#7
someone mind letting me know if I changed this properly...


<script>
<![CDATA[
function OnPluginPacketReceived (s)
  return (string.gsub (s, "> ", ""))
end -- function OnPluginPacketReceived
]]>
</script>


I had it working where it would put the newline after the stupid > prompt... but I got bugged by the spam eventually... I think this fixes it, and it seems to work thus far. There aren't many situations in the mud where I can think of removing >'s to be a bad thing... But I just want to make sure that this will only remove "> " if it is the first part of a line? Thanks folks.
Australia Forum Administrator #8
You are probably better off adding a newline, like this:


function OnPluginPacketReceived (s)
  return (string.gsub (s, "\n> ", "%1\n"))
end -- function OnPluginPacketReceived


Then make a trigger to omit that. However I suppose omitting it right now isn't so silly, but I would look for the newline first, otherwise anything that says "> " in the message will have it omitted, eg.



function OnPluginPacketReceived (s)
  return (string.gsub (s, "\n> ", ""))
end -- function OnPluginPacketReceived
#9
Ok, I tried your second bit alone, but it doesn't display the two lines on different lines. So trying to keep it all in one little script, I think this answers the concern that it might omit stuff.


function OnPluginPacketReceived (s)
  return (string.gsub (s, "\n> ", "\n"))
end -- function OnPluginPacketReceived


just to give an example, here is raw feedback after sending two commands (including the echoed commands)... as an after thought. I just noticed when I selected it, and pasted it there is another trailing > on the same line, that doesn't actually display.

show skills parry
show skills control
parry: Legendary.
> control: A Grand Master.
>

which this plugin by itself replaces as follows...

show skills parry
show skills control
parry: Legendary.
control: A Grand Master.

So it seems to work. Does it address the concern you pointed out? Or did I manage to make it worse somehow, lol...

I found one situation where it doesn't seem to work... that is whenever I send the mud a carriage return it will send me back the following... Don't understand why it doesn't fire here.

"

> "
Amended on Sun 19 Apr 2009 04:01 PM by LupusFatalis
#10
Actually, I think I'm onto something as to why..

Here, i type in the command who and receive:
Name Idle Time
a damp elf 26s
a furry cushion 8s
a passionate soldier
a worthless fool
Abraxas the rowan
an ardent ranger 32s
Azoron the rowan
Domik the human 32s
Fisher the human
Maerwen the elf 48s
Tikeeke the spyder 6m 15s
[HG] Troylance the rowan 16s
We extrapolate that there are 15 players on. Only 12 returned their census forms.
Estimated active characters: 180 this month, 50 today.
Ferdarchi was last renewed 6 days 41 minutes 16 seconds ago.
>

Later, the mud sends more feedback as something happens internally, etc... This new feedback ends the line.

> Your aura appears to be intense blue.

So this script doesn't seem to fire until it receives an entire line. But by the time it receives the entire line it has been too late and doesn't run in some cases.
#11
As an aside...

function OnPluginPacketReceived (s)
  return (string.gsub (s, "> ", ""))
end -- function OnPluginPacketReceived

Does catch everything and fix it all... But I do recognize the distinct possibility that something goes haywire when I enter a room that has...

part of a desc > another part of a desc

although... I just ran a test without the plugin
say sfasfd > heya
You say in common, 'Sfasfd > heya'
>

with the plugin
say sfasfd > heya
You say in common, 'Sfasfd heya'

Maybe I'm misinterpreting where you think it will have an error? Like I said, I'm not really positive what this lua code is doing... it seems to be replacing all old text with the new text... having it replace > in the middle of a paragraph with "" is less of a problem for me than having the > at the beginning screw up all my triggers... its not ideal, and I'd like to fix it, but if the solution is too complicated, don't worry about it. Thanks again bud, you've been a great help.
Amended on Sun 19 Apr 2009 04:35 PM by LupusFatalis
Australia Forum Administrator #12
Quote:

Maybe I'm misinterpreting where you think it will have an error?


Your second example, with the plugin, does exactly what I thought it would - remove "> " from any text, not just at the beginning of the line.

My idea with the \n> was sound, however I seem to recall someone else who had difficulty with that found there were colour codes as well at the start of the line. A "packet debug" of a prompt would help.

Go to Edit menu -> Debug packets, capture a prompt or two, and turn it off again. Then copy and paste (here) the relevant packet. Probably there is something like:


(newline) (some colour codes) >


Now without the colour codes as part of the string.gsub, it won't match.

#13
Incoming packet: 139 (25 bytes) at Monday, April 20, 2009, 1:46:40 AM

urs 17 minutes 2 75 72 73 20 31 37 20 6d 69 6e 75 74 65 73 20 32
3 seconds 33 20 73 65 63 6f 6e 64 73

Incoming packet: 140 (13 bytes) at Monday, April 20, 2009, 1:46:40 AM

ago....[0m> 20 61 67 6f 2e 0d 0a 1b 5b 30 6d 3e 20

Incoming packet: 141 (61 bytes) at Monday, April 20, 2009, 1:46:41 AM

Your aura appear 59 6f 75 72 20 61 75 72 61 20 61 70 70 65 61 72
s to be .[1;37mi 73 20 74 6f 20 62 65 20 1b 5b 31 3b 33 37 6d 69
ntense .[0m.[1;3 6e 74 65 6e 73 65 20 1b 5b 30 6d 1b 5b 31 3b 33
4mblue.[0m... 34 6d 62 6c 75 65 1b 5b 30 6d 2e 0d 0a
#14
Incoming packet: 136 (41 bytes) at Monday, April 20, 2009, 1:46:37 AM

parry: 70 61 72 72 79 3a 20 20 20 20 20 20 20 20 20 20
Legen 20 20 20 20 20 20 20 20 20 20 20 4c 65 67 65 6e
dary...> 64 61 72 79 2e 0d 0a 3e 20

Incoming packet: 137 (46 bytes) at Monday, April 20, 2009, 1:46:37 AM

control: 63 6f 6e 74 72 6f 6c 3a 20 20 20 20 20 20 20 20
A Gra 20 20 20 20 20 20 20 20 20 20 20 41 20 47 72 61
nd Master...> 6e 64 20 4d 61 73 74 65 72 2e 0d 0a 3e 20
#15
ok so it seems as if the following works on the majority

function OnPluginPacketReceived (s)
  return (string.gsub (s, "\n> ", "\n"))
end -- function OnPluginPacketReceived

however, it does not work on all of them, for the rest the following works, but I can't seem to get the rest to work due to the "[" it throws an error... I used an \ before the bracket but it still says expecting "]" or some such...

function OnPluginPacketReceived (s)
  return (string.gsub (s, "0m> ", ""))
end -- function OnPluginPacketReceived


How can I combine this to catch both cases with a newline on each?
Australia Forum Administrator #16
Quote:

0d 0a 1b 5b 30 6d 3e 20


You have: \r \n \027 [ 0 m >

In Lua regular expressions, you have to escape a square bracket with a % rather than a backslash.

Quote:

How can I combine this to catch both cases with a newline on each?


Something like this:


function OnPluginPacketReceived (s)
  s = string.gsub (s, "\r\n\027%[0m> ", "")
  return (string.gsub (s, "\r\n> ", ""))
end -- function OnPluginPacketReceived


The first string.gsub deals with the lines with the ANSI sequence in it, the second then fixes up the others.
Amended on Tue 21 Apr 2009 03:45 AM by Nick Gammon
#17
function OnPluginPacketReceived (s)
  s = string.gsub (s, "\r\n\027%[0m> ", "\n\027%[0m")
  return (string.gsub (s, "\r\n> ", "\n"))
end -- function OnPluginPacketReceived

So, I had to add back in the \n, because I'm removing a new line without it in there. Also, in the first portion, I added the color code back in, as it was changing the colors, etc... similarly it also needed a new line. Now, the only time I see the > is when I send a carriage return. In which case I see a blank line and then a line with only the "> " on it.

Sent  packet: 65 (2 bytes) at Tuesday, April 21, 2009, 12:30:45 AM

..                 0d 0a

Incoming packet: 82 (2 bytes) at Tuesday, April 21, 2009, 12:30:45 AM

>                  3e 20


I tried adding in your omit blank lines plugin as well, to get of half the spam in that instance, but it doesn't seem to be the issue.
Amended on Tue 21 Apr 2009 04:48 AM by LupusFatalis
Australia Forum Administrator #18
What you said makes sense. :) I probably stripped away too many newlines.

You could always fix the problem with the packet with just 3e 20 in it by adding a line:


if s == "> " then
  return ""
end -- if only a prompt


#19
works so far, it seems to be gone from everything but when I first log, which is no big deal. Thanks again Nick!
#20
Looks like I spoke too soon Nick, I have to get this one as well...

Incoming packet: 4152 (999 bytes) at Friday, April 24, 2009, 1:21:59 AM


.[1mGymnasium.[0   1b 5b 31 6d 47 79 6d 6e 61 73 69 75 6d 1b 5b 30
m..This is the t   6d 0d 0a 54 68 69 73 20 69 73 20 74 68 65 20 74
raining hall whe   72 61 69 6e 69 6e 67 20 68 61 6c 6c 20 77 68 65
re the members o   72 65 20 74 68 65 20 6d 65 6d 62 65 72 73 20 6f
f the Palace Gua   66 20 74 68 65 20 50 61 6c 61 63 65 20 47 75 61
rd work out and    72 64 20 77 6f 72 6b 20 6f 75 74 20 61 6e 64 20
hone their skill   68 6f 6e 65 20 74 68 65 69 72 20 73 6b 69 6c 6c
s.   One entire    73 2e 20 20 20 4f 6e 65 20 65 6e 74 69 72 65 20
wall is covered    77 61 6c 6c 20 69 73 20 63 6f 76 65 72 65 64 20
by a wooden rack   62 79 20 61 20 77 6f 6f 64 65 6e 20 72 61 63 6b
 to hold weapons   20 74 6f 20 68 6f 6c 64 20 77 65 61 70 6f 6e 73
 and shields and   20 61 6e 64 20 73 68 69 65 6c 64 73 20 61 6e 64
 a target stands   20 61 20 74 61 72 67 65 74 20 73 74 61 6e 64 73
 near the opposi   20 6e 65 61 72 20 74 68 65 20 6f 70 70 6f 73 69
te wall.  Near t   74 65 20 77 61 6c 6c 2e 20 20 4e 65 61 72 20 74
he rack is a sma   68 65 20 72 61 63 6b 20 69 73 20 61 20 73 6d 61
ll bronze gong h   6c 6c 20 62 72 6f 6e 7a 65 20 67 6f 6e 67 20 68
angs on the wall   61 6e 67 73 20 6f 6e 20 74 68 65 20 77 61 6c 6c
.  Several ropes   2e 20 20 53 65 76 65 72 61 6c 20 72 6f 70 65 73
 hang from the r   20 68 61 6e 67 20 66 72 6f 6d 20 74 68 65 20 72
afters and the b   61 66 74 65 72 73 20 61 6e 64 20 74 68 65 20 62
ack wall appears   61 63 6b 20 77 61 6c 6c 20 61 70 70 65 61 72 73
 to be rough, wi   20 74 6f 20 62 65 20 72 6f 75 67 68 2c 20 77 69
th many protrusi   74 68 20 6d 61 6e 79 20 70 72 6f 74 72 75 73 69
ons.  In the bac   6f 6e 73 2e 20 20 49 6e 20 74 68 65 20 62 61 63
k corner, a poli   6b 20 63 6f 72 6e 65 72 2c 20 61 20 70 6f 6c 69
shed brass pole    73 68 65 64 20 62 72 61 73 73 20 70 6f 6c 65 20
reaches from the   72 65 61 63 68 65 73 20 66 72 6f 6d 20 74 68 65
 floor to the ce   20 66 6c 6f 6f 72 20 74 6f 20 74 68 65 20 63 65
iling.  The area   69 6c 69 6e 67 2e 20 20 54 68 65 20 61 72 65 61
 is .[37m.[1mglo   20 69 73 20 1b 5b 33 37 6d 1b 5b 31 6d 67 6c 6f
wing.[0m .[30m.[   77 69 6e 67 1b 5b 30 6d 20 1b 5b 33 30 6d 1b 5b
1mfaintly.[0m.     31 6d 66 61 69 6e 74 6c 79 1b 5b 30 6d 2e 20 20
It is blindingly   49 74 20 69 73 20 62 6c 69 6e 64 69 6e 67 6c 79
 bright here....   20 62 72 69 67 68 74 20 68 65 72 65 2e 0d 0a 1b
[1;37mThere is o   5b 31 3b 33 37 6d 54 68 65 72 65 20 69 73 20 6f
ne obvious exit.   6e 65 20 6f 62 76 69 6f 75 73 20 65 78 69 74 1b
[0m: .[0;36mwest   5b 30 6d 3a 20 1b 5b 30 3b 33 36 6d 77 65 73 74
.[0m...a wooden    1b 5b 30 6d 2e 0d 0a 61 20 77 6f 6f 64 65 6e 20
wagon (hitched t   77 61 67 6f 6e 20 28 68 69 74 63 68 65 64 20 74
o Dour), an open   6f 20 44 6f 75 72 29 2c 20 61 6e 20 6f 70 65 6e
 cedar cask of w   20 63 65 64 61 72 20 63 61 73 6b 20 6f 66 20 77
ater, and a stor   61 74 65 72 2c 20 61 6e 64 20 61 20 73 74 6f 72
age bin...Drab t   61 67 65 20 62 69 6e 2e 0d 0a 44 72 61 62 20 74
he black palfrey   68 65 20 62 6c 61 63 6b 20 70 61 6c 66 72 65 79
...Dour the blac   2e 0d 0a 44 6f 75 72 20 74 68 65 20 62 6c 61 63
k destrier (pull   6b 20 64 65 73 74 72 69 65 72 20 28 70 75 6c 6c
ing a wooden wag   69 6e 67 20 61 20 77 6f 6f 64 65 6e 20 77 61 67
on)...a sparring   6f 6e 29 2e 0d 0a 61 20 73 70 61 72 72 69 6e 67
 golem (attackin   20 67 6f 6c 65 6d 20 28 61 74 74 61 63 6b 69 6e
g Fey)...a sparr   67 20 46 65 79 29 2e 0d 0a 61 20 73 70 61 72 72
ing golem (attac   69 6e 67 20 67 6f 6c 65 6d 20 28 61 74 74 61 63
king Fey)...Fey    6b 69 6e 67 20 46 65 79 29 2e 0d 0a 46 65 79 20
the spyder (atta   74 68 65 20 73 70 79 64 65 72 20 28 61 74 74 61
cking Golem)...D   63 6b 69 6e 67 20 47 6f 6c 65 6d 29 2e 0d 0a 44
ismal the rowan    69 73 6d 61 6c 20 74 68 65 20 72 6f 77 61 6e 20
(blurry)...Junyl   28 62 6c 75 72 72 79 29 2e 0d 0a 4a 75 6e 79 6c
 the catfolk (ly   20 74 68 65 20 63 61 74 66 6f 6c 6b 20 28 6c 79
ing on the floor   69 6e 67 20 6f 6e 20 74 68 65 20 66 6c 6f 6f 72
)...Captain Nazi   29 2e 0d 0a 43 61 70 74 61 69 6e 20 4e 61 7a 69
r the cadet mast   72 20 74 68 65 20 63 61 64 65 74 20 6d 61 73 74
er...a target du   65 72 2e 0d 0a 61 20 74 61 72 67 65 74 20 64 75
mmy...>            6d 6d 79 2e 0d 0a 3e


think you can give me a hand?

right now I am using...


function OnPluginPacketReceived (s)
  s = string.gsub (s, "\r\n\027%[0m> ", "\n\027%[0m")
  s = string.gsub (s, "\r\n> ", "\n")
  
  if s == "> " then 
    return ""
  else
    return (s)
  end

end -- function OnPluginPacketReceived
Amended on Sat 25 Apr 2009 04:18 AM by Nick Gammon
Australia Forum Administrator #21
You mean the very last one? Looks like it is at the end of the packet (999 bytes) and probably the MUD has broken the output up at the 999 byte mark. It is hard to catch those without batching up packets.
#22
hmm... I guess its a no-go then. No biggy, I'll try to look at it later when I understand more about these packets and such. Thanks again though.
Australia Forum Administrator #23
This thread has an example of concatenating packets until you get a whole line:

http://mushclient.com/forum/?id=7430

What you can do in OnPluginPacketReceived is concatenate packets first (storing a partial line in the plugin), and then extract out whole lines. These can then be reliably checked for prompts.
#24
Ok, now I'm unfamiliar with LUA, so bear with me... Here is what I have after looking at that page...
partial = ""

function OnPluginPacketReceived (s)

	partial = partial .. string.gsub (s, "\r", "")
	t = {}

	partial = string.gsub (partial, "(.-)\n", 
		function (line) 
		table.insert (t, line) 
		return ""
		end)

	partial = string.gsub (partial, "\r\n\027%[0m> ", "\n\027%[0m")
	partial = string.gsub (partial, "\r\n> ", "\n")
	
	if partial == "> " then 
		partial = ""
	end

	if table.getn (t) > 0 then
		table.insert (t, "")
	end

	return table.concat (t, "\n")

end


Now, I hope I'm doing this correctly... The triggering on regular expressions didn't work to get rid of the "> ". So its not currently in the plugin.
#25
There are several places where it goes awry:
1)
Incoming packet: 2 (614 bytes) at Saturday, April 25, 2009, 3:41:56 PM

            _..    20 20 20 20 20 20 20 20 20 20 20 20 5f 0d 0a 20
          | |..    20 20 20 20 20 20 20 20 20 20 7c 20 7c 0d 0a 20
   _ _ _ _|:|___   20 20 20 5f 20 5f 20 5f 20 5f 7c 3a 7c 5f 5f 5f
________________   5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f
________________   5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f
___..  O(_|_|_|_   5f 5f 5f 0d 0a 20 20 4f 28 5f 7c 5f 7c 5f 7c 5f
|:|_____________   7c 3a 7c 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f
________________   5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f
_________>..       5f 5f 5f 5f 5f 5f 5f 5f 5f 3e 0d 0a 20 20 20 20
       |:|..       20 20 20 20 20 20 20 7c 3a 7c 0d 0a 20 20 20 20
       |_|   The   20 20 20 20 20 20 20 7c 5f 7c 20 20 20 54 68 65
 Creators of Dar   20 43 72 65 61 74 6f 72 73 20 6f 66 20 44 61 72
tMUD ....          74 4d 55 44 20 0d 0a 0d 0a 20 20 20 20 20 20 20
                   20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
Welcome You To .   57 65 6c 63 6f 6d 65 20 59 6f 75 20 54 6f 20 0d
...                0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20
               T   20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 54
he Lands of Ferd   68 65 20 4c 61 6e 64 73 20 6f 66 20 46 65 72 64
archi!..           61 72 63 68 69 21 0d 0a 20 20 20 20 20 20 20 20
                   20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
                   20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
  _..     The or   20 20 5f 0d 0a 20 20 20 20 20 54 68 65 20 6f 72
iginal and still   69 67 69 6e 61 6c 20 61 6e 64 20 73 74 69 6c 6c
 the best!    |    20 74 68 65 20 62 65 73 74 21 20 20 20 20 7c 20
| -Since-..   __   7c 20 2d 53 69 6e 63 65 2d 0d 0a 20 20 20 5f 5f
________________   5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f
________________   5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f
____|:|_ _ _ _ .   5f 5f 5f 5f 7c 3a 7c 5f 20 5f 20 5f 20 5f 20 0d
.  <____________   0a 20 20 3c 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f
________________   5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f
__________|:|_|_   5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 7c 3a 7c 5f 7c 5f
|_|_)O ..          7c 5f 7c 5f 29 4f 20 0d 0a 20 20 20 20 20 20 20
                   20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
                   20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
  |:| ..           20 20 7c 3a 7c 20 0d 0a 20 20 20 20 20 20 20 20
  [Version 1.3.1   20 20 5b 56 65 72 73 69 6f 6e 20 31 2e 33 2e 31
-3.2.1]            2d 33 2e 32 2e 31 5d 20 20 20 20 20 20 20 20 20
 |_| 1 9 9 1....   20 7c 5f 7c 20 31 20 39 20 39 20 31 0d 0a 0d 0a
Name:              4e 61 6d 65 3a 20

Incoming packet: 3 (13 bytes) at Saturday, April 25, 2009, 3:41:59 PM

Password: ÿû.      50 61 73 73 77 6f 72 64 3a 20 ff fb 01


It doesn't actually display the query "Name:" and "Password:" until after I have already typed them in...
#26
2)
Incoming packet: 5 (5 bytes) at Saturday, April 25, 2009, 3:42:01 PM

ÿü.>               ff fc 03 3e 20

Incoming packet: 6 (47 bytes) at Saturday, April 25, 2009, 3:42:02 PM

.[32mYou're brig   1b 5b 33 32 6d 59 6f 75 27 72 65 20 62 72 69 67
ht-eyed and bush   68 74 2d 65 79 65 64 20 61 6e 64 20 62 75 73 68
y-tailed..[0m..    79 2d 74 61 69 6c 65 64 2e 1b 5b 30 6d 0d 0a


This actually displays as follows:
> You're bright-eyed and bushy-tailed.
#27
3)
Incoming packet: 8 (999 bytes) at Saturday, April 25, 2009, 3:42:08 PM

.[36m       Name   1b 5b 33 36 6d 20 20 20 20 20 20 20 4e 61 6d 65
                   20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
     Idle          20 20 20 20 20 49 64 6c 65 20 20 20 20 20 20 20
    Name           20 20 20 20 4e 61 6d 65 20 20 20 20 20 20 20 20
             Idl   20 20 20 20 20 20 20 20 20 20 20 20 20 49 64 6c
e.[0m..       .[   65 1b 5b 30 6d 0d 0a 20 20 20 20 20 20 20 1b 5b
1;31ma determine   31 3b 33 31 6d 61 20 64 65 74 65 72 6d 69 6e 65
d ranger.[0m       64 20 72 61 6e 67 65 72 1b 5b 30 6d 20 20 20 20
  1m 46s           20 20 31 6d 20 34 36 73 20 20 20 20 20 20 20 20
 .[0;36ma furry    20 1b 5b 30 3b 33 36 6d 61 20 66 75 72 72 79 20
herbalist.[0m      68 65 72 62 61 6c 69 73 74 1b 5b 30 6d 20 20 20
     2s      ..    20 20 20 20 20 32 73 20 20 20 20 20 20 0d 0a 20
      a hapless    20 20 20 20 20 20 61 20 68 61 70 6c 65 73 73 20
adventurer     1   61 64 76 65 6e 74 75 72 65 72 20 20 20 20 20 31
2s            .[   32 73 20 20 20 20 20 20 20 20 20 20 20 20 1b 5b
1;36ma helpful c   31 3b 33 36 6d 61 20 68 65 6c 70 66 75 6c 20 63
rafter.[0m         72 61 66 74 65 72 1b 5b 30 6d 20 20 20 20 20 20
  14s     ..       20 20 31 34 73 20 20 20 20 20 0d 0a 20 20 20 20
   .[1;36ma hung   20 20 20 1b 5b 31 3b 33 36 6d 61 20 68 75 6e 67
ry houri.[0m       72 79 20 68 6f 75 72 69 1b 5b 30 6d 20 20 20 20
       20s         20 20 20 20 20 20 20 32 30 73 20 20 20 20 20 20
      .[1;37ma p   20 20 20 20 20 20 1b 5b 31 3b 33 37 6d 61 20 70
atient wanderer.   61 74 69 65 6e 74 20 77 61 6e 64 65 72 65 72 1b
[0m       16s      5b 30 6d 20 20 20 20 20 20 20 31 36 73 20 20 20
  ..       .[1;3   20 20 0d 0a 20 20 20 20 20 20 20 1b 5b 31 3b 33
3ma peerless cat   33 6d 61 20 70 65 65 72 6c 65 73 73 20 63 61 74
folk.[0m       4   66 6f 6c 6b 1b 5b 30 6d 20 20 20 20 20 20 20 34
s             .[   73 20 20 20 20 20 20 20 20 20 20 20 20 20 1b 5b
1;37ma sparkly e   31 3b 33 37 6d 61 20 73 70 61 72 6b 6c 79 20 65
lfess.[0m          6c 66 65 73 73 1b 5b 30 6d 20 20 20 20 20 20 20
  4s      ..       20 20 34 73 20 20 20 20 20 20 0d 0a 20 20 20 20
   Abraxas the r   20 20 20 41 62 72 61 78 61 73 20 74 68 65 20 72
owan        14s    6f 77 61 6e 20 20 20 20 20 20 20 20 31 34 73 20
           Avar    20 20 20 20 20 20 20 20 20 20 20 41 76 61 72 20
the gnome          74 68 65 20 67 6e 6f 6d 65 20 20 20 20 20 20 20
    2s      ..     20 20 20 20 32 73 20 20 20 20 20 20 0d 0a 20 20
     Azoron the    20 20 20 20 20 41 7a 6f 72 6f 6e 20 74 68 65 20
rowan         10   72 6f 77 61 6e 20 20 20 20 20 20 20 20 20 31 30
s            Cat   73 20 20 20 20 20 20 20 20 20 20 20 20 43 61 74
era the braman     65 72 61 20 74 68 65 20 62 72 61 6d 61 6e 20 20
      34s     ..   20 20 20 20 20 20 33 34 73 20 20 20 20 20 0d 0a
       Daelin th   20 20 20 20 20 20 20 44 61 65 6c 69 6e 20 74 68
e human            65 20 68 75 6d 61 6e 20 20 20 20 20 20 20 20 20
56s            D   35 36 73 20 20 20 20 20 20 20 20 20 20 20 20 44
omik the human     6f 6d 69 6b 20 74 68 65 20 68 75 6d 61 6e 20 20
        20s        20 20 20 20 20 20 20 20 32 30 73 20 20 20 20 20
..       Fisher    0d 0a 20 20 20 20 20 20 20 46 69 73 68 65 72 20
the human          74 68 65 20 68 75 6d 61 6e 20 20 20 20 20 20 20
  38s       .[32   20 20 33 38 73 20 20 20 20 20 20 20 1b 5b 33 32
m[.[0m.[31mB.[0m   6d 5b 1b 5b 30 6d 1b 5b 33 31 6d 42 1b 5b 30 6d
.[37mH.[0m.[32m]   1b 5b 33 37 6d 48 1b 5b 30 6d 1b 5b 33 32 6d 5d
.[0m Kuktuchik t   1b 5b 30 6d 20 4b 75 6b 74 75 63 68 69 6b 20 74
he spyder          68 65 20 73 70 79 64 65 72 20 20 20 20 20 20 20
      ..  .[32m[   20 20 20 20 20 20 0d 0a 20 20 1b 5b 33 32 6d 5b
.[0m.[31mB.[0m.[   1b 5b 30 6d 1b 5b 33 31 6d 42 1b 5b 30 6d 1b 5b
37mH.[0m.[32m].[   33 37 6d 48 1b 5b 30 6d 1b 5b 33 32 6d 5d 1b 5b
0m Napala the el   30 6d 20 4e 61 70 61 6c 61 20 74 68 65 20 65 6c
f           3m 5   66 20 20 20 20 20 20 20 20 20 20 20 33 6d 20 35
2s         Wodeu   32 73 20 20 20 20 20 20 20 20 20 57 6f 64 65 75
m the human        6d 20 74 68 65 20 68 75 6d 61 6e 20 20 20 20 20
    2s      ...[   20 20 20 20 32 73 20 20 20 20 20 20 0d 0a 1b 5b
36m  We extrapol   33 36 6d 20 20 57 65 20 65 78 74 72 61 70 6f 6c
ate tha            61 74 65 20 74 68 61

Incoming packet: 9 (25 bytes) at Saturday, April 25, 2009, 3:42:08 PM

t there are 23 p   74 20 74 68 65 72 65 20 61 72 65 20 32 33 20 70
layers on          6c 61 79 65 72 73 20 6f 6e

Incoming packet: 10 (226 bytes) at Saturday, April 25, 2009, 3:42:08 PM

.  Only 18 retur   2e 20 20 4f 6e 6c 79 20 31 38 20 72 65 74 75 72
ned their census   6e 65 64 20 74 68 65 69 72 20 63 65 6e 73 75 73
 forms...  Most    20 66 6f 72 6d 73 2e 0d 0a 20 20 4d 6f 73 74 20
people seem to b   70 65 6f 70 6c 65 20 73 65 65 6d 20 74 6f 20 62
e in Tirachi rig   65 20 69 6e 20 54 69 72 61 63 68 69 20 72 69 67
ht now...  Estim   68 74 20 6e 6f 77 2e 0d 0a 20 20 45 73 74 69 6d
ated active char   61 74 65 64 20 61 63 74 69 76 65 20 63 68 61 72
acters: 190 this   61 63 74 65 72 73 3a 20 31 39 30 20 74 68 69 73
 month, 70 today   20 6d 6f 6e 74 68 2c 20 37 30 20 74 6f 64 61 79
...  Ferdarchi w   2e 0d 0a 20 20 46 65 72 64 61 72 63 68 69 20 77
as last renewed    61 73 20 6c 61 73 74 20 72 65 6e 65 77 65 64 20
12 days 4 hours    31 32 20 64 61 79 73 20 34 20 68 6f 75 72 73 20
13 minutes 20 se   31 33 20 6d 69 6e 75 74 65 73 20 32 30 20 73 65
conds ago....[0m   63 6f 6e 64 73 20 61 67 6f 2e 0d 0a 1b 5b 30 6d
>                  3e 20

Sent  packet: 6 (3 bytes) at Saturday, April 25, 2009, 3:42:10 PM

l..                6c 0d 0a

Incoming packet: 11 (24 bytes) at Saturday, April 25, 2009, 3:42:10 PM

It is pitch blac   49 74 20 69 73 20 70 69 74 63 68 20 62 6c 61 63
k.  ..>            6b 2e 20 20 0d 0a 3e 20


This actually displays as...
[The Who List, etc...]
> It is pitch black.

Australia Forum Administrator #28
Quote:

partial = string.gsub (partial, "(.-)\n",
function (line)
table.insert (t, line)
return ""
end)

partial = string.gsub (partial, "\r\n\027%[0m> ", "\n\027%[0m")
partial = string.gsub (partial, "\r\n> ", "\n")


No, once you have done the string.gsub, all the lines except the last partial one will be in the table "t", not in the string "partial", so doing a string.gsub on that won't achieve anything.

So now you have a table of lines, so you do your matches on that, eg.


partial = ""

function OnPluginPacketReceived (s)

  -- get rid of carriage-returns
  
  partial = partial .. string.gsub (s, "\r", "")
  local t = {}

  -- turn finished lines into table t
  
  partial = string.gsub (partial, "(.-)\n", 
    function (line) 
    table.insert (t, line) 
    return ""
    end)

  -- get rid of prompts  (in a regexp, ^ indicates the start of a line)
  
  for i, line in ipairs (t) do
    t [i] = string.gsub (line, "^\027%[0m> ", "\027%[0m")
    t [i] = string.gsub (line, "^> ", "")
  end -- for
  
  -- reassemble completed packet with line-based corrections
  
  local fixed_packet = ""
  
  -- drop completely empty lines
  for i, line in ipairs (t) do
    if line ~= "" then
      fixed_packet = fixed_packet .. line .. "\n"
    end -- if
  end -- for
  
  return fixed_packet

end -- OnPluginPacketReceived


(Disclaimer: I didn't test or compile the above code).

Quote:

It doesn't actually display the query "Name:" and "Password:" until after I have already typed them in...


That is exactly what you expect to happen if you batch up lines until you get a newline character. You probably need to do nothing with the incoming packets until some flag is set to indicate you have finished the login sequence.

Or, use the "auto-login" function in MUSHclient which sends down the username and password as soon as you connect, so they will be supplied even if you don't see the question.
Amended on Sun 26 Apr 2009 09:27 PM by Nick Gammon
Australia Forum Administrator #29
More simply, you might fix up the prompts as you build the table, like this:


partial = ""

function OnPluginPacketReceived (s)

  local t = {}  -- table of reassembled lines

  -- get rid of carriage-returns, add new packet to existing partial one
  
  partial = partial .. string.gsub (s, "\r", "")

  -- turn finished lines into table t
  
  partial = string.gsub (partial, "(.-)\n", 
    function (line) 
      
      -- remove prompt as we add to the table
      
      line = string.gsub (line, "^\027%[0m> ", "\027[0m", 1)
      line = string.gsub (line, "^> ", "", 1)
         
      if line ~= "" then
        table.insert (t, line) 
      end -- if not empty
      
      return ""
    end) -- function
  
  if #t > 0 then
    table.insert (t, "")  -- to get final linefeed
  end -- if
    
  -- return table of lines, concatenated with newlines between each one
  return table.concat (t, "\n")

end -- OnPluginPacketReceived

Amended on Sun 26 Apr 2009 09:43 PM by Nick Gammon
#30
Ah, that works much better. I haven't rigorously tested to find where it doesn't work as desired. It seems like when getting and mud mail I have to disable it. No big deal there. If I get any glaring errors I'll give a post about it. But so far so good, thanks a lot bud.
#31
Ok, this is just the relevant parts of the packets I believe but here is what happens, I log in, and get my room desc. I send anything to the mud and get the response beginning with > .... Now i'm not sure if this error will crop up in other situations, but if possible I want to eliminate it.

50 33 36 6d 77 65 73 74 1b 5b 30 6d 2e 0d 0a 35 30
2 iron weights.. 32 20 69 72 6f 6e 20 77 65 69 67 68 74 73 2e 0d
.ÿü.ÿü.> 0a ff fc 01 ff fc 03 3e 20

Sent packet: 3 (3 bytes) at Thursday, April 30, 2009, 4:43:16 PM

l.. 6c 0d 0a

Incoming packet: 4 (409 bytes) at Thursday, April 30, 2009, 4:43:17 PM

.[1mA garden.[0m 1b 5b 31 6d 41 20 67 61 72 64 65 6e 1b 5b 30 6d
..A small garden 0d 0a 41 20 73 6d 61 6c 6c 20 67 61 72 64 65 6e
looks very well 20 6c 6f 6f 6b 73 20 76 65 72 79 20 77 65 6c 6c
tended.

...502 iron weights.
> A garden
A small garden looks very well tended.

At the moment, I've modified the code a little... it is as follows:
partial = ""

function OnPluginPacketReceived (s)

  local t = {}  -- table of reassembled lines

  if s == "> " then
    s = ""
  end

  -- get rid of carriage-returns, add new packet to existing partial one

  partial = partial .. string.gsub (s, "\r", "")

  -- turn finished lines into table t
  
  partial = string.gsub (partial, "(.-)\n", 
    function (line) 
      
      -- remove prompt as we add to the table
      
      line = string.gsub (line, "^\027%[0m> ", "\027[0m", 1)
      line = string.gsub (line, "^> ", "", 1)
         
      if line ~= "" then
        table.insert (t, line) 
      end -- if not empty
      
      return ""
    end) -- function
  
  if #t > 0 then
    table.insert (t, "")  -- to get final linefeed
  end -- if
    
  -- return table of lines, concatenated with newlines between each one
  return table.concat (t, "\n")

end
Australia Forum Administrator #32
It looks like you are getting telnet sequences. This stuff:


0a ff fc 01 ff fc 03 3e 20


is:

  • newline (oa)
  • IAC WONT 01 (I won't echo)
  • IAC WONT 03 (I won't suppress go-ahead)


The extras stuff before the prompt (who knows why it is there exactly?) is what is stopping the plugin suppress the prompt. I'm not sure if we should completely eliminate it, but probably changing the order is OK. eg.

Change:


-- get rid of carriage-returns, add new packet to existing partial one

  partial = partial .. string.gsub (s, "\r", "")



to:


-- get rid of carriage-returns, add new packet to existing partial one

  partial = partial .. string.gsub (s, "\r", "")

  partial = string.gsub (partial, "\n\255\252\001", "\255\252\001\n")
  partial = string.gsub (partial, "\n\255\252\003", "\255\252\003\n")


This is moving the telnet stuff to before the newline, so it will still be processed by MUSHclient, however now the tests further down will notice the prompt following the newline.
#33
So far so good! Thanks again nick.
Australia Forum Administrator #34
Quote:

Basically, what I want to happen is have the most recent lines (perhaps 10) still displayed at the bottom whenever I scroll back. This way I'm able to react to current events while looking back in time.


See: http://www.gammon.com.au/forum/?id=9454
#35
Checked it out. That is exactly that I imagining at the beginning of this (except matching colors, but no big deal there).

Much thanks!