[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]  Python
. . -> [Subject]  Python error while using trigger
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Python error while using trigger

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


Posted by Shwick   (21 posts)  [Biography] bio
Date Sun 23 May 2010 02:54 AM (UTC)  quote  ]

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.


[Go to top] top

Posted by Nick Gammon   Australia  (19,339 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Sun 23 May 2010 06:15 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Nick Gammon   Australia  (19,339 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Sun 23 May 2010 07:24 AM (UTC)  quote  ]
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
[Go to top] top

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


1,982 views.

[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]