check if a trigger is enabled

Posted by Lilbopeep on Sat 09 Jun 2012 06:32 AM — 5 posts, 22,943 views.

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

Netherlands #1
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.
Amended on Sat 09 Jun 2012 07:00 AM by Worstje
USA #2
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.
Netherlands #3
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.)
Netherlands #4
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.)