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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Python
. . -> [Subject]  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] Refresh page


Posted by Icewolf   (17 posts)  [Biography] 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
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] 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
[Go to top] top

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

Posted by Icewolf   (17 posts)  [Biography] 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?
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] 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
[Go to top] top

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

Posted by Icewolf   (17 posts)  [Biography] 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...
[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.


18,657 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 HostDash]