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 ➜ Python error while using trigger

Python error while using trigger

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


Posted by Shwick   (21 posts)  Bio
Date Sun 23 May 2010 02:54 AM (UTC)

Amended on Sun 23 May 2010 03:00 AM (UTC) by Shwick

Message
I have a trigger calling a python script. The script works when the trigger regex is "hai", but doesn't when it's "Hunger".

haiTrigger - http://img532.imageshack.us/img532/7906/haitrigger.jpg
haiOutput - http://img4.imageshack.us/img4/1215/haioutput.jpg
hungerTrigger - http://img139.imageshack.us/img139/646/hungertrigger.jpg
hungerOutput - http://img59.imageshack.us/img59/8051/hungeroutput.jpg

As you can see the triggers are exactly the same except for the regex, but one gives an error.

The script is,


def OnStats (strTriggerName, trig_line, wildcards):
  world.Note ("hi")


The scripts file is named "pythonScripts.py", it does not have the .pys extension used in the example file.

I'm using python 2.6 and I installed the script engine using pywin32-214.win32-py2.6.exe.
Using Mushclient 4.33, windows xp 32 pro.

I've done lots of reading and can't find an answer, help is appreciated.


Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 23 May 2010 06:15 AM (UTC)
Message
Rather than posting images it is easier just to use the Copy button and paste the text right here.

Template:copying For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.


Anyway, your problem seems to me to be that you are sending the matching line "to script" as well as calling a script.

Leave the Send box empty (delete the %0) and leave the "send to" box as "World".

You are doing the work in OnStats (which is called anyway, even if you don't do "send to script"). Using "send to script" tries to evaluate what is in the Send box as Python commands which probably won't work.

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #2 on Sun 23 May 2010 07:24 AM (UTC)
Message
Template:scripting Scripting tutorial

There is extensive information about scripting in MUSHclient at http://mushclient.com/scripting. This includes screen shots and examples.


- Nick Gammon

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

Posted by Shwick   (21 posts)  Bio
Date Reply #3 on Mon 24 May 2010 03:39 AM (UTC)
Message
thanks that solved my problem
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.


15,123 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.