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

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  check if a trigger is enabled
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

check if a trigger is enabled

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


Posted by Lilbopeep   USA  (42 posts)  [Biography] bio
Date Sat 09 Jun 2012 06:32 AM (UTC)
Message
i've searched and searched but i've not had any luck figuring out how to simply check and see if one of my triggers is enabled or disabled.

I have a block of triggers that are all grouped under the same name that get turned on and off by an alias. It makes sense I cant just check and see if they are all on or off without some fancy footwork, but I figured it would be easy to just check if any one of them was.


,.~`'~.,Dance Magic Dance,.~`'~.,
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] bio
Date Reply #1 on Sat 09 Jun 2012 06:51 AM (UTC)

Amended on Sat 09 Jun 2012 07:00 AM (UTC) by Worstje

Message
if (GetTriggerOption("my_trigger", "enabled") == 1) then
  Note("My trigger is enabled.")
else  -- not enabled (GTO would have returned 0)
  Note("Bummer. It ain't workin'.")
end

There is also the GetTriggerInfo() call, which is a bit older and does no specify the information by the 'name' of the setting, but by an integer. Advantage though is that booleans return actual booleans with that one.

if GetTriggerInfo("my_trigger", 8) then
  Note("My trigger is enabled.")
else  -- not enabled
  Note("Bummer. It ain't workin'.")
end

Also, remember that the above samples do no error-checking. If the trigger doesn't exist, or some other problem happens, the return value is nil in both cases.
[Go to top] top

Posted by Lilbopeep   USA  (42 posts)  [Biography] bio
Date Reply #2 on Sat 09 Jun 2012 07:14 AM (UTC)
Message
before I give myself more headaches...


if im checking for a trigger that isnt in the plugin that the above script example you gave me, will that cause problems and if so how do I get by it, beyond moving everything into one plugin which isnt really what I want..

Otherwise


if (GetTriggerOption("fishscript", "enabled") == 1) then
CallPlugin ("126d9061f9758498c878a204", "MsgNote", "auto_fish is ON", "White", "Green")
else
CallPlugin ("126d9061f9758498c878a204", "MsgNote", "auto_fish is OFF", "White", "Green")
end


always returns off, despite me toggling it over and over.

,.~`'~.,Dance Magic Dance,.~`'~.,
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] bio
Date Reply #3 on Sat 09 Jun 2012 07:29 AM (UTC)
Message
Try GetPluginTriggerInfo(). The first parameer is the unique id of the plugin you also use for CallPlugin(). As for the details, see the help function inside MUSHclient.

Be warned though; hard-coding such relationships between your plugins carelessly means that they become very hard to use separately, seemingly 'random' breaking and so forth. If your code is intended to be part of a bigger whole, consider using Lua require() and include() commands instead. (Example: You have a system that handles your combat. But a plugin that only deals with tracking illnesses has no use i the main module isn't loaded, and this will only confuse your users.)
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] bio
Date Reply #4 on Sun 10 Jun 2012 01:46 AM (UTC)
Message
Try GetPluginTriggerInfo(). The first parameer is the unique id of the plugin you also use for CallPlugin(). As for the details, see the help function inside MUSHclient.

Be warned though; hard-coding such relationships between your plugins carelessly means that they become very hard to use separately, seemingly 'random' breaking and so forth. If your code is intended to be part of a bigger whole, consider using Lua require() and include() commands instead. (Example: You have a system that handles your combat. But a plugin that only deals with tracking illnesses has no use i the main module isn't loaded, and this will only confuse your users.)
[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.


3,849 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 FutureQuest]