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

Gammon Forum

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

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Python
. . -> [Subject]  Calling OnPluginPartialLine from Python
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Calling OnPluginPartialLine from Python

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


Posted by Tom Geudens   (2 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (21,674 posts)  [Biography] 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
[Go to top] top

Posted by Tom Geudens   (2 posts)  [Biography] 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
[Go to top] top

Posted by Nick Gammon   Australia  (21,674 posts)  [Biography] 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
[Go to top] top

Posted by Ked   Russia  (524 posts)  [Biography] 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.
[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.


4,974 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

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

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]