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 ➜ Lua ➜ check if a trigger is enabled

check if a trigger is enabled

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


Posted by Lilbopeep   USA  (42 posts)  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,.~`'~.,
Top

Posted by Worstje   Netherlands  (899 posts)  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.
Top

Posted by Lilbopeep   USA  (42 posts)  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,.~`'~.,
Top

Posted by Worstje   Netherlands  (899 posts)  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.)
Top

Posted by Worstje   Netherlands  (899 posts)  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.)
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.


17,287 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.