Thread Tools Display Modes
11-03-10, 04:29 AM   #1
ministoat
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 9
can you stop addon based on player spec?

I'm wondering if there's a way to stop an addon functioning if the character isn't in a certain spec.

For example, I have an eclipse bar addon, can I stop this addon if the character doesn't have the moonkin form talent?
  Reply With Quote
11-03-10, 04:52 AM   #2
yj589794
A Rage Talon Dragon Guard
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 314
Yes, you can. look how Blizzards own eclipse bar gets shown/hidden:

https://github.com/tekkub/wow-ui-sou...rFrame.lua#L36
  Reply With Quote
11-03-10, 06:53 AM   #3
ministoat
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 9
excellent thankyou!

added a line and now it only does it's thing in balance spec:

Code:
if UnitClass("player") == "Druid" then
    if GetPrimaryTalentTree() == 1 then -- this is the new line <3
	f = CreateFrame("Frame", "FakePlayerFrame");
	f.unit = "player";
	EclipseBarFrame:SetParent(FakePlayerFrame);
	EclipseBarFrame:ClearAllPoints();
	EclipseBarFrame:SetPoint("CENTER", "UIParent", "CENTER", 0, -195);
	EclipseBarFrame:Show();
	EclipseBarFrame:SetScale(0.8);
	end
end
  Reply With Quote
11-03-10, 07:00 AM   #4
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Maybe not very relevant, but you can make that a little shorter.

Code:
if UnitClass("player") == "Druid" and GetPrimaryTalentTree() == 1 then
	f = CreateFrame("Frame", "FakePlayerFrame");
	f.unit = "player";
	EclipseBarFrame:SetParent(FakePlayerFrame);
	EclipseBarFrame:ClearAllPoints();
	EclipseBarFrame:SetPoint("CENTER", "UIParent", "CENTER", 0, -195);
	EclipseBarFrame:Show();
	EclipseBarFrame:SetScale(0.8);
end
  Reply With Quote
11-03-10, 07:04 AM   #5
Lyelu
A Cyclonian
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 44
If your Addon supports profiles, you can also use Tattoo (v000004). I put a function in there that switches all profiles named "Heal" "DPS" or "Tank" for mods that support profiles. Works on Bartender, Grid, etc, to rearrange your layout on a typed command /heal /dps or /tank.

But it is a graphics mod, so it's bundled with background panels.

There is also Reflux, which works much differently, actually creating profiles for you on all your mods. Read the user comments before you try that, so you know what to expect.

Then in case you run up on this problem again for another mod, you won't have to edit each mod by hand, and then have your edits gone when it's time to update them.
  Reply With Quote
11-03-10, 09:42 AM   #6
ministoat
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 9
nah shorter is good, thanks haleth!

Lyelu - thanks for the info, but I wasn't looking to increase the number of addons i'm using
  Reply With Quote
11-03-10, 11:56 AM   #7
Nobgul
A Molten Giant
 
Nobgul's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 693
Wouldn't the code above only fire on addon loaded unless you hooked it to a update script?
I mean if you login as resto and then change to boomkin would it update and show?

FrameName:RegisterEvent("UPDATE_SHAPESHIFT_FORMS");

Just wondering because I am thinking about doing this for my eclipse bar.
__________________
[SIGPIC][/SIGPIC]
  Reply With Quote
11-03-10, 03:35 PM   #8
ministoat
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 9
yeah I have used the event "ACTIVE_TALENT_GROUP_CHANGED"

I put this into an alpha script and it seems to work, I think I need to add another event though, the bar disappeared a few times in ICC today.


Code:
 local a = CreateFrame("Frame")
  a:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
  a:RegisterEvent("PLAYER_UPDATE_RESTING")
  a:RegisterEvent("PLAYER_REGEN_ENABLED")
  a:RegisterEvent("PLAYER_REGEN_DISABLED")
  a:RegisterEvent("PLAYER_ENTERING_WORLD")
  

  a:SetScript("OnEvent", function(self,event)
    if event == "PLAYER_ENTERING_WORLD" then
        EclipseBarFrame:SetAlpha(0.2)
	elseif event == "ACTIVE_TALENT_GROUP_CHANGED" then
    	EclipseBarFrame:SetAlpha(0.2)	
    elseif event == "PLAYER_UPDATE_RESTING" then
    	EclipseBarFrame:SetAlpha(0.2)
	elseif event == "PLAYER_REGEN_ENABLED" then
    	EclipseBarFrame:SetAlpha(0.2)
    else
     EclipseBarFrame:SetAlpha(1)
    end
  end)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » can you stop addon based on player spec?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off