[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Tips and tricks
. . -> [Subject]  Forcing newlines on prompt lines

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Forcing newlines on prompt lines
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Pages: 1 2  3  4  

Posted by Full Metal   (1 post)  [Biography] bio
Date Thu 08 Sep 2005 12:47 PM (UTC)  quote  ]
Message
I am new to this mushclient but i'm playing achaea and this newline trick is vital.
An enhancement to the gagging trigger would be to use the GetLineCount function. In Vbscript, my blank line gagging trigger is linked to this sub.

Sub GagBlankLine (name, line, wildcards)

dim Prompt
Prompt = World.GetVariable ("PromptLine")

If World.GetLineCount > Prompt + 1 Then
World.Note " "
End If

End Sub


I assume that there is a sub processing the prompt, the trick is to use GetLineCount to get the unique line number of the prompt and to put it in a Variable with World.SetVariable.

Now just link the gagging trigger to a simple sub which will compare the line number of the gag trigger to the line number of the last prompt. Now if the difference is greater than one, it would mean that this "new line" has not been "forced" and this "new line" is coming from the mud which could easily be re_created with a world.send " ".
[Go to top] top

Posted by Nexes   (65 posts)  [Biography] bio
Date Fri 20 May 2005 02:15 AM (UTC)  quote  ]

Amended on Sat 21 May 2005 04:53 AM (UTC) by Nexes

Message
Ked, when I try to put your plugin in I get a bunch of errors:

Traceback (innermost last):
File "<Script Block >", line 4, in ?
terminated = False
NameError: False

Line in error:
terminated = False

Line 21: Error parsing script (problem in this file)

I don't really know what the problem is since I can't read Python. Could anyone help me?

EDIT: Its the second script you posted by the way.

EDIT: I got it fixed, just had to restart the computer to get python to reload. Then I had to change the pat1 expression to another one listed here.
[Go to top] top

Posted by Tsunami   USA  (204 posts)  [Biography] bio
Date Wed 13 Apr 2005 02:08 PM (UTC)  quote  ]
Message
You're my hero Nick! Sort of.
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Wed 13 Apr 2005 01:56 AM (UTC)  quote  ]
Message
Version 3.66 now released. :)

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Tsunami   USA  (204 posts)  [Biography] bio
Date Tue 12 Apr 2005 07:34 PM (UTC)  quote  ]
Message
Release 3.66 sometime soon please... I'm begging you here Nick ;) ?
[Go to top] top

Posted by DT   (1 post)  [Biography] bio
Date Tue 12 Apr 2005 04:53 PM (UTC)  quote  ]
Message
Hiya, umm, I'm sort of having a similar problem with MUSH, and Achaea and after having pretty much experienced all of the above! I was wondering if I could get some help with these scripts, me having to pick up what I can from examples etc. :)

Basically, I used the updated script by Nick, and got the extra spaces, the weird newlines on things that aren't prompts, so I went back to the first one that was put up.

I'm also using that "Deletes the empty spaces trigger" using "^$", which is a little inconvenient but works, expecially since I've never heard of Python before, or could figure out which bits to change into VBscript (which is what I'm using).

Well, now theres a slight problem that the prompt isn't being picked up, on -every- prompt that comes, basically whenever a few lines are sent rapidly to the world consecutively... possibly its not the fact they're being sent, but that information is coming back too fast...

Its frustrating, especially when important triggers are set for those lines and they aren't recognised... I can't quite seem to figure out how to make either:

1 The prompt be recognised regardless of whats in front or behind (perhaps if the plugin isn't detecting it for some reason).
or 2 Make a trigger, that will send the real command back through the system, since what I've been doing mostly, is putting a trigger that captures stuff that might be tagged onto a prompt and reoutputting it, minus prompt stuff. This doesn't trigger anything though.

Wow, hope that was easy to understand, I'm running 3.65 so any help would be greatly appreciated! Thanks.
[Go to top] top

Posted by Bobble   Canada  (76 posts)  [Biography] bio
Date Wed 16 Mar 2005 02:25 PM (UTC)  quote  ]
Message
Hey Ked!

Seems to work like a charm! Thanks for all your help, it's much appreciated.

Open the watch.
[Go to top] top

Posted by Ked   Russia  (524 posts)  [Biography] bio
Date Wed 16 Mar 2005 12:52 AM (UTC)  quote  ]
Message
And try to optionally include/exclude the 'u' before the pattern string, to see what works.
[Go to top] top

Posted by Ked   Russia  (524 posts)  [Biography] bio
Date Wed 16 Mar 2005 12:50 AM (UTC)  quote  ]
Message
Once again - very strange. Either your Python is screwed up, or mine is :) The problem is that the GA regexp is set to match on the Unicode escape of "\u044f\u0449", which is what I get, but in your case it seems that the GA code is the normal "\xff\xf9". So to fix it, simply replace the pattern for pat1 with: "(\-\xff\xf9)($|\x0d\x0a)?". The extra option in the second group, seems to capture most of the extra lines, and won't hurt in any case.
[Go to top] top

Posted by Bobble   Canada  (76 posts)  [Biography] bio
Date Wed 16 Mar 2005 12:36 AM (UTC)  quote  ]

Amended on Wed 16 Mar 2005 12:42 AM (UTC) by Bobble

Message
The output to the screen looked like this:
You remove 1 kelp, bringing the total in the cache to 104.
H:3260 M:3479 E:10672 W:17420 B:100% [db eb]You remove 1 irid moss, bringing the total in the cache to 69.

The output to the notepad was:
u'You remove 1 kelp, bringing the total in the cache to 104.\r\n\x1b[32mH:3260\x1b[37m\x1b[32m M:3479\x1b[37m\x1b[1;33m E:10672\x1b[0;37m\x1b[32m W:17420\x1b[37m\x1b[1;31m B:100%\x1b[0;37m [db eb]\xff\xf9'u'You remove 1 irid moss, bringing the total in the cache to 69.\r\n\x1b[32mH:3260\x1b[37m\x1b[32m M:3479\x1b[37m\x1b[1;33m E:10672\x1b[0;37m\x1b[32m W:17420\x1b[37m\x1b[1;31m B:100%\x1b[0;37m [db eb]\xff\xf9'

Open the watch.
[Go to top] top

Posted by Ked   Russia  (524 posts)  [Biography] bio
Date Wed 16 Mar 2005 12:23 AM (UTC)  quote  ]
Message
Strange, it works for me on Achaea, although it still has the same problem as Lusternia's server-side prompt newlines - extra empty lines every once in a while. About the only thing that comes to my mind is that you somehow managed to get the non-Unicode version of Python, or maybe pywin32. Replace the OnPluginPacketReceived function with the following one and post the output it gives:


def OnPluginPacketReceived(packet):
    global terminated, pat1,pat2
    world.AppendToNotepad("test", repr(packet))
    if terminated:
        packet = pat2.sub("",packet)
        terminated = False
    packet = pat1.sub(repl, packet)
    return packet

[Go to top] top

Posted by Bobble   Canada  (76 posts)  [Biography] bio
Date Tue 15 Mar 2005 11:03 PM (UTC)  quote  ]

Amended on Tue 15 Mar 2005 11:04 PM (UTC) by Bobble

Message
Hi Ked!

Thanks for all your help, but I'm still not having any luck with this plugin. It's not adding any new line breaks. I wish I could give you more instructive feed back, but I don't know python or how to read packets all that well.

Here are the changes I made to the plugin:
pat1 = re.compile(u"(\]\u044f\u0449)($)?")
and
return "]\x0d\x0a"

Here's a sample of some output I got when I spammed getting several different herbs from my cache:
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 prickly ash bark, bringing the total in the cache to 101.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 goldenseal root, bringing the total in the cache to 111.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 kelp, bringing the total in the cache to 106.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 lobelia seed, bringing the total in the cache to 98.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 ginseng root, bringing the total in the cache to 134.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 bellwort flower, bringing the total in the cache to 135.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 slippery elm, bringing the total in the cache to 112.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 bloodroot leaf, bringing the total in the cache to 74.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 valerian, bringing the total in the cache to 17.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 skullcap, bringing the total in the cache to 118.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 irid moss, bringing the total in the cache to 71.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 hawthorn berry, bringing the total in the cache to 83.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 bayberry bark, bringing the total in the cache to 27.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 sileris, bringing the total in the cache to 13.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 black cohosh, bringing the total in the cache to 115.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 kola nut, bringing the total in the cache to 94.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 echinacea, bringing the total in the cache to 27.

As you can see, the newlines aren't being added at all. Is there any more information I could give you that might help solve this problem?

Open the watch.
[Go to top] top

Posted by Ked   Russia  (524 posts)  [Biography] bio
Date Tue 15 Mar 2005 08:50 PM (UTC)  quote  ]
Message
This one replaces any and all GA codes it finds in a packet, still supressing extra newlines. You'll also need to replace the "-" char with your "]". The previous one only replaced the GA found at the very end of the packet, meaning that all other prompts were left untouched.


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Sunday, March 13, 2005, 4:11 PM -->
<!-- MuClient version 3.65 -->

<!-- Plugin "PromptCatcher_Achaea" generated by Plugin Wizard -->

<muclient>
<plugin
   name="PromptCatcher_Achaea"
   author="Keldar"
   id="8f85913ad96bd5bc255e434a"
   language="Python"
   purpose="Capturing prompts"
   date_written="2005-03-13 16:10:15"
   requires="3.65"
   version="1.0"
   >

</plugin>
<script>
<![CDATA[
import re
pat1 = re.compile(u"(\-\u044f\u0449)($)?")
pat2 = re.compile("^\x0d\x0a")
terminated = False

def repl(mo):
    global terminated
    if mo.groups()[1] == "":
        terminated = True
    return "-\x0d\x0a"
        
def OnPluginPacketReceived(packet):
    global terminated, pat1,pat2
    if terminated:
        packet = pat2.sub("",packet)
        terminated = False
    packet = pat1.sub(repl, packet)
    return packet


]]>
</script>

</muclient>
[Go to top] top

Posted by Bobble   Canada  (76 posts)  [Biography] bio
Date Tue 15 Mar 2005 04:10 PM (UTC)  quote  ]

Amended on Tue 15 Mar 2005 04:13 PM (UTC) by Bobble

Message
Hey Ked!

I got python scripting up and running, so I gave this plugin a whirl. It's not putting any new lines in at all, which makes me think I haven't altered the plugin to properly catch the last character of a prompt line in Aetolia.

Prompts in Aetolia look like this:
H:3038 M:3579 E:15200 W:17420 B:100% [db eb]

They always end with the "]" character. With this in mind, I altered one line of the plugin as such:
pat1 = re.compile(u"\]\u044f\u0449$")

The "\-" has been replaced by "\]" now. But it doesn't seem to match this as the end of the prompt and no new lines are being added. Have I made this alteration correctly or is there something else that must be done?

As always, any help is appreciated.


Open the watch.
[Go to top] top

Posted by Ked   Russia  (524 posts)  [Biography] bio
Date Sun 13 Mar 2005 06:56 PM (UTC)  quote  ]
Message
Instead of appending newlines to prompts, on IRE games you could use a temporary patch (until version 3.66 comes out). The following plugin replaces the GO AHEAD codes (\ff\f9) which appear at the end of the packet with newlines (\0d\0a) and suppresses the extra newlines at the beginning of the next packet if GA was already replaced, removing the need for additional triggers to suppress extra empty lines, which result from duplicate newlines being produced. It's in Python since I didn't want to deal with Replace anymore, but it shouldn't be too hard to port to something else. The GA pattern is supposed to only match if it follows the "-" character (the last char in an Achaea prompt) so it would need to be replaced by something that's appropriate in your case:


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Sunday, March 13, 2005, 4:11 PM -->
<!-- MuClient version 3.65 -->

<!-- Plugin "PromptCatcher_Achaea" generated by Plugin Wizard -->

<muclient>
<plugin
   name="PromptCatcher_Achaea"
   author="Keldar"
   id="8f85913ad96bd5bc255e434a"
   language="Python"
   purpose="Capturing prompts"
   date_written="2005-03-13 16:10:15"
   requires="3.65"
   version="1.0"
   >

</plugin>
<script>
<![CDATA[
import re
pat1 = re.compile(u"\-\u044f\u0449$")
pat2 = re.compile("^\x0d\x0a")
terminated = False

#from time import clock

def OnPluginPacketReceived(packet):
	global terminated, pat1,pat2
	#start = clock()
	m1 = pat1.match(packet[len(packet)-3:])
	m2 = pat2.match(packet[:2])
	if m1:
		terminated = True
		packet = packet[:len(packet)-2] + "\x0d\x0a"
	if m2:
		if terminated:
			packet = packet[2:]
			terminated = False
	#timing = clock() - start
	#world.AppendToNotepad("test", repr(packet) + "\r\n")
	#world.Note (timing)
	return packet


]]>
</script>

</muclient>
[Go to top] 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.


13,829 views.

This is page 1, subject is 4 pages long: 1 2  3  4  [Next page]

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]