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 ➜ SetTriggerOption/GetTriggerOption "name" option doesn't work

SetTriggerOption/GetTriggerOption "name" option doesn't work

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


Posted by Icewolf   (17 posts)  Bio
Date Mon 10 May 2010 11:26 PM (UTC)
Message
world.GetTriggerOption("bla", "name") # always return None

world.SetTriggerOption("bla", "name", "bla") # return 30025

My MC version:4.43

Python version: 2.6
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #1 on Mon 10 May 2010 11:28 PM (UTC)
Message
It's not a Python issue, it's a general API issue. And it's not an issue at all according to Nick:

http://www.gammon.com.au/forum/?id=10069

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #2 on Tue 11 May 2010 12:14 AM (UTC)
Message
Icewolf said:

world.GetTriggerOption("bla", "name") # always return None


The name is "bla" - you don't need to query it.


Icewolf said:

world.SetTriggerOption("bla", "name", "bla") # return 30025


You can't rename triggers. The name is the key. Changing the name changes the key, effectively turning it into a different trigger. You need to delete it and re-add it, if that is what you want to do. See ExportXML and ImportXML.

- Nick Gammon

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

Posted by Icewolf   (17 posts)  Bio
Date Reply #3 on Tue 11 May 2010 03:05 AM (UTC)
Message
Nick Gammon said:

Icewolf said:

world.GetTriggerOption("bla", "name") # always return None


The name is "bla" - you don't need to query it.


Icewolf said:

world.SetTriggerOption("bla", "name", "bla") # return 30025


You can't rename triggers. The name is the key. Changing the name changes the key, effectively turning it into a different trigger. You need to delete it and re-add it, if that is what you want to do. See ExportXML and ImportXML.


Thanks Nick!

The XML approach is very elegant - I like it. However, one issue I am concerned with is that, according to the document, *XML() functions' return values seem not convey as much information as the Add*/Set*/Get* functions.

Is that true?
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #4 on Tue 11 May 2010 04:16 AM (UTC)
Message
If you're getting into tweaking trigger options at runtime, you might want to check out my Reflex library.

http://www.gammon.com.au/forum/?id=10073

There are examples of how to use it there, as well as the source so you can save it to your MUSHclient/lua/ folder and use it yourself.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #5 on Tue 11 May 2010 05:48 AM (UTC)
Message
Icewolf said:

The XML approach is very elegant - I like it. However, one issue I am concerned with is that, according to the document, *XML() functions' return values seem not convey as much information as the Add*/Set*/Get* functions.


Both return whether they worked or not, one way or another. That should be enough to confirm it succeeded. In any case, exporting a trigger should be in a format guaranteed to import OK afterwards.

- Nick Gammon

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

Posted by Icewolf   (17 posts)  Bio
Date Reply #6 on Tue 11 May 2010 12:40 PM (UTC)
Message
Twisol said:

If you're getting into tweaking trigger options at runtime, you might want to check out my Reflex library.

http://www.gammon.com.au/forum/?id=10073

There are examples of how to use it there, as well as the source so you can save it to your MUSHclient/lua/ folder and use it yourself.


Yes. That looks like exactly what I'm doing in Python. I built a more "pythonic" interfaces for the trigger/alias/timer on top of mushclient's interfaces.

"Reflex" is one of the features - allows users to access mushclient items' options using dictrionaries:

trigger['anOption']


Items are created by instantiating the corresponding python classes, and using python's *keyword* argument feature:


aTrig = Trigger("aPattern", name="bla", group="bla", script="some")


As I said, some more pythonic ways are also used, too. Like decorators:


@Trigger.decorate("aPattern", name="bla", group="bla")
def call_back_function(line, name, wildcards):
  # do something
  pass


The above piece of code defines a trigger and use "call_back_function" as the "script" option of that trigger. Very convenient.

There are some other things I'm building currently. Like Gammon's "wait" module (I was inspired by the other post about Python coroutines: http://www.gammon.com.au/forum/?id=8277); Convenient logging utilities by which the normal stdout or other string streams can be directed to mushclient's notepads.

I may want to put those stuff on line so that others can test and use soon...
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.


21,521 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.