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 ➜ Python ➜ Calling OnPluginPartialLine from Python

Calling OnPluginPartialLine from Python

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


Posted by Tom Geudens   (2 posts)  Bio
Date Wed 05 Jan 2005 06:15 PM (UTC)
Message
Greetings all,
I'm a beginner in all this (this being MUSHclient, plugins/scripting and Python). I was trying to rewrite a couple of the VBscripts in Python ... and most of them go well, but I failed with the OnPluginPartialLine ...

I wrote the following :
import re
def OnPluginPartialLine(sText):
world.InfoClear ()
world.Info ("Before Compile - ")
myregexp = re.compile("^(.*?)h\, (.*?)m\ ex(.*?)\-$")
world.Info ("After Compile ")
mymatch = myregexp.match(str(sText))

And wanted to build on that ...
However, I'm getting Type Mismatch errors for every
line the MUD (Lusternia) is giving me.

Can anyone help me out here ?
Regards,
Tom

P.S. My apologies if this has already been covered
somewhere, I've read several scripts but found no-one
that called OnPluginPartialLine from Python.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Wed 05 Jan 2005 07:13 PM (UTC)
Message
Does the compile fail, or the match?

- Nick Gammon

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

Posted by Tom Geudens   (2 posts)  Bio
Date Reply #2 on Wed 05 Jan 2005 07:26 PM (UTC)
Message
Well, actually it gives me trouble whatever I put
in the function, including when I leave out the
mymatch = myregexp.match(str(sText))

What I'm trying to accomplish (if it isn't obvious :-)
is that triggers would fire on my MUDprompt (which
looks like 3093h, 2580m, 2238e, 10p ex-)without
waiting for the carriage return. I've found several
scripts that could possibly accomplish this on the
forums (and at the moment I'm checking the one you
wrote in LUA with the OnPluginPacketReceived function)
but I'm having no success converting them to Python.

Regards,
Tom Geudens
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #3 on Wed 05 Jan 2005 09:09 PM (UTC)
Message
What I suggest you do is use the Lua plugin, or a variant, that simply has the job of adding the newline. All you need to do is get the regexp right for your prompt.

Then you can write a normal trigger, in Python or any other language, to process the prompt. The Lua plugin simply makes the trigger fire immediately by adding the newline.

- Nick Gammon

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

Posted by Ked   Russia  (524 posts)  Bio
Date Reply #4 on Wed 12 Jan 2005 08:28 AM (UTC)
Message
I used to have the same problem and it turned out to be easy to solve. Apparently Python's COM bindings are acting up, not sure what exactly the problem is, but it seems to be caused by Python automatically returning some value on each call to OnPluginPartialLine and Mushclient or COM, or something out there, expecting a different type of value. Anyways, the easy solution is to make sure that OnPluginPartialLine ALWAYS returns True (or False if that makes sense). Just make sure that you have a "return True" statement at every potential exit from the function and you'll be okay.
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.


18,063 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.