Removing repeating lines from output

Posted by xxRezinxx on Wed 13 May 2015 06:22 PM — 9 posts, 38,146 views.

USA #0
I recently added a chat window plugin in my client. Following instructions in one of your earlier posts. It works great! Thank you! But now, in my main window, with my character standing still for a few minutes I end up getting my prompt over and over until it fills up the main window.
I have seen this problem mentioned in a couple of posts but not a solution anywhere.

<100hp 100m 100mv>

<100hp 100m 100mv>

<100hp 100m 100mv>

<100hp 100m 100mv>


Is it possible to create a script or trigger something along the lines of:
get line_1: ^(.*?)$
get line_2: ^(.*?)$
if line_2 == line_1
---then hidefromoutput=y
---reevaulate line_2
else hidefromoutput=n

<100hp 100m 100mv>
-hidden-
-hidden-
-hidden-
You went north.
<100hp 100m 100mv>
USA Global Moderator #1
Yes.

If you always get the prompt immediately after a chat line, then you could create a disabled trigger that gags the next incoming line and then disables itself. You would enable that trigger when you gag a chat line.

You could also create a gagging trigger that gags a particular line, and then change the pattern to match the previous line sent every time a new line comes in.
Amended on Wed 13 May 2015 06:50 PM by Fiendish
Australia Forum Administrator #2
I usually use an "omit blank lines" trigger (ships with the client) that fixes one of those two lines.

As for the prompt, the simple thing is to make a trigger that matches your prompt (whatever it is) and omits it. Then inside the trigger you see if the prompt is different from last time. If it is different you display it from the trigger.
USA Global Moderator #3
Nick Gammon said:

As for the prompt, the simple thing is to make a trigger that matches your prompt (whatever it is)

Déjà vu
http://www.gammon.com.au/forum/?id=10728&reply=98#reply98
Amended on Wed 13 May 2015 08:10 PM by Fiendish
Australia Forum Administrator #4
Certainly, reply #97:

Quote:

This is a fairly common problem, because the MUD sends two prompts. You may have suppressed the "You say 'hello' " message but you haven't suppressed the second prompt.

One approach is to detect prompt lines in a trigger, omit them, and then in a script detect if the prompt has changed. If it is different, echo it (Note or ColourNote it). That suppresses multiple identical prompts.
USA Global Moderator #5
I prefer #98 and #99 ;)
USA #6
Nick still hasn't said that is a good approach to the problem, just a very simple one.
USA #7
The blank-line removal plugin helps significantly. After reading some of the other comments I'm on the fence about hiding the prompt.
USA Global Moderator #8
Note: Important context for this first part is that I write plugins primarily for other people, not for myself.

Hiding any particular text pattern, including just blank lines, without attention to context, can have negative consequences. In this case you're making it so that the game can never send you two blank lines for any reason ever. That could be as harmless(?) as not seeing what an area builder intends or in the most extreme case could break some other plugin. Either way, it's a bit "sledgehammer for a nail". You'll definitely drive the nail, but you may also split the surrounding wood.

You need to hide the next lines after any hidden chat, right? That's useful context that you could use.

But it shouldn't be too hard to evaluate your own situation by asking two questions:
1) Do you care about missing double blanks/prompts that exist for other reasons?
2) Do you want anyone else to be able to use this without having to edit the script for their own prompt?

You might answer no to both and stop worrying. :)