Python error while using trigger

Posted by Shwick on Sun 23 May 2010 02:54 AM — 4 posts, 19,716 views.

#0
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.


Amended on Sun 23 May 2010 03:00 AM by Shwick
Australia Forum Administrator #1
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.
Australia Forum Administrator #2
Template:scripting
Scripting tutorial

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

#3
thanks that solved my problem