WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   enable/disable addon based on class. (https://www.wowinterface.com/forums/showthread.php?t=35337)

clix 10-08-10 11:47 PM

enable/disable addon based on class.
 
I am trying to make a addon that enables/disables other addons based on the character class.

exp.
If class = hunter & addon = XXXX is not on, enable it
or
if class is not = hunter & addon "hunter addon" is enabled, disable addon.

coding exp (currently not working)

Code:

local playerClass, englishClass = UnitClass("player");

if (playerClass == "Hunter") then
    if not (IsAddOnLoaded("Tyra Misdirection")) then
      EnableAddOn("Tyra Misdirection")
      ReloadUI()
    end
end

if (playerClass == "Rogue") then
    if (IsAddOnLoaded("Tyra Misdirection")) then
      DisableAddOn("Tyra Misdirection")
      ReloadUI()
    end
end

The code is currently reading that the class is indeed hunter/rogue. But isn't doing anything beyond that.

Rilgamon 10-09-10 12:35 AM

You can select addons to be loaded in the addon settings for each char.
Guess thats faster than writing an addon.
Or you can ask the addonauthors to add support for

http://www.wowwiki.com/AddonLoader

which can load addons classbased and does not need an uireload.

clix 10-09-10 12:40 AM

Quote:

Originally Posted by Rilgamon (Post 208553)
You can select addons to be loaded in the addon settings for each char.
Guess thats faster than writing an addon.
Or you can ask the addonauthors to add support for

http://www.wowwiki.com/AddonLoader

which can load addons classbased and does not need an uireload.


I know I am able to do it via wow settings. But just trying to do it via addon so I don't have to worry about it upon switching computers, which I seem to do a lot.

Rilgamon 10-09-10 06:45 AM

http://www.wowwiki.com/API_ReloadUI

The function ReloadUI is protected. Which means you cant call it without
the user clicking key or mouse. So you would need to create a button
to prompt for the reload when needed.

Grimsin 10-09-10 07:53 AM

Not to mention most addons that are class specific have their own class loaders in them. I know mine do....

mentalnutsy 10-14-10 10:12 AM

What i do with Nutty War Announce is have the addon disable for next login if the class that logs in with it is not a warrior. You should be able to edit the below code to suit yourself easy enough.

Code:

function NuttyWarAnnounce:OnInitialize()
if select(2,UnitClass("player")) == "WARRIOR" then
    print("|cffFF0000Nutty War Announce:|r |cff00FF00Enabled|r")
            elseif not Warrior then
    print("|cffFF0000Nutty War Announce:|r |cff00FF00Not a warrior. Disabling addon for next login|r")
      DisableAddOn("NuttyWarAnnounce")
      enabled = false
end

end


Edit: Sorry read the thread wrong. Hope this can be of some use tho.

Nuggs 10-16-10 12:24 AM

what i do with my warlock addon is

Code:

local function nDemonic_Disable()
        DisableAddOn("nDemonic");
        ReloadUI();
end

StaticPopupDialogs["DISABLE_NDEMONIC"] = {
        text = "You're not currently logged into a warlock, disabling the AddOn.",
        button1 = "Accept", OnAccept = nDemonic_Disable, timeout = 0, whileDead = 1,
};

function nDemonic:PLAYER_LOGIN()
        if (select(2,UnitClass("player")) == "WARLOCK") then
                nDemonic:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
                nDemonic:RegisterEvent("PLAYER_DEAD");
                nDemonic:RegisterEvent("ZONE_CHANGED_NEW_AREA");
        else
                StaticPopup_Show("DISABLE_NDEMONIC");
        end
        nDemonic:UnregisterEvent("PLAYER_LOGIN");
end

Reason for that is I think you have to invoke the reloading of the UI through clicking instead of having it reload without user interaction.


All times are GMT -6. The time now is 07:49 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI