Elitist Jerks
Register
Blogs
Forums


Go Back   Elitist Jerks » User Interface and AddOns

Reply
 
LinkBack Thread Tools
Old 02/19/09, 12:27 PM   #1
diospadre
Hero of the Horde
 
diospadre's Avatar
 
Undead Warrior
 
Mal'Ganis
Target Event/API

I use this bit of code (that I stole from nRune) to show/hide various frames when i enter/exit combat. I would like to modify it so that the frames show when I enter combat or have a target, but have not been able to find an event that will allow me to do this. Can anyone point me in the right direction?

    addon:SetScript("OnEvent", function()
        if (event == "PLAYER_ENTERING_WORLD" or event == "PLAYER_REGEN_ENABLED") then
            RuneFrame:SetAlpha(0)
	    MultiBarBottomLeft:Hide()
        elseif (event == "PLAYER_REGEN_DISABLED") then
            RuneFrame:SetAlpha(.7)
	    MultiBarBottomLeft:Show()
        end
    end)

United States Offline
Reply With Quote
Old 02/19/09, 12:33 PM   #2
Duncan
Piston Honda
 
Human Paladin
 
Das Syndikat (EU)
I don't know if you have seen it, yet. But you should definitely take a look at this - Kong UI Hider. This might help, I hope.

Offline
Reply With Quote
Old 02/19/09, 1:01 PM   #3
diospadre
Hero of the Horde
 
diospadre's Avatar
 
Undead Warrior
 
Mal'Ganis
That can hide/show based on combat, which I'm already able to do. I'm looking for a way to hide/show based on when I have a target.

United States Offline
Reply With Quote
Old 02/19/09, 1:11 PM   #4
Timewasted
Don Flamenco
 
Timewasted's Avatar
 
Human Death Knight
 
Proudmoore
I would think that adding a check for either "UnitExists("target")" or "UnitName("target") ~= nil" would do what you want. There's also a PLAYER_TARGET_CHANGED event, but it seems that you'd end up calling UnitExists or UnitName anyways.

Originally Posted by ebbv View Post
I like to arrange gingerbread men like they're running away from me in terror and then crush them all.

Offline
Reply With Quote
Old 02/19/09, 2:51 PM   #5
• Chicken
 
Chicken's Avatar
 
Ginakursia
Goblin Warlock
 
No WoW Account (EU)
Originally Posted by Timewasted View Post
I would think that adding a check for either "UnitExists("target")" or "UnitName("target") ~= nil" would do what you want. There's also a PLAYER_TARGET_CHANGED event, but it seems that you'd end up calling UnitExists or UnitName anyways.
Specifically, what you probably want to add is:

elseif (event == PLAYER_TARGET_CHANGED) then
    if (UnitExists("target"))
        RuneFrame:SetAlpha(.7)
	MultiBarBottomLeft:Show()
    else
        RuneFrame:SetAlpha(0)
	MultiBarBottomLeft:Hide()
    end
I can't guarantee it'll work.

Edit: That's probably missing a check whether you're in combat or not.

Last edited by Chicken : 02/19/09 at 3:09 PM.

Netherlands Online
Reply With Quote
Old 02/19/09, 5:06 PM   #6
diospadre
Hero of the Horde
 
diospadre's Avatar
 
Undead Warrior
 
Mal'Ganis
Time and Chicken: thanks for the help. You got me halfway there and now I have it working just as I wanted. Here's my final code.

    if (event == "PLAYER_TARGET_CHANGED") then
     if (not InCombatLockdown() and UnitExists("target")) then
        RuneFrame:SetAlpha(1) end
     if (not InCombatLockdown() and not UnitExists("target")) then      
	RuneFrame:SetAlpha(0.1)
	end
end

United States Offline
Reply With Quote
Reply

Go Back   Elitist Jerks » User Interface and AddOns

Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
5 second rule event in the API? Shocktar Public Discussion 19 06/20/07 1:17 PM
Event question Analyze User Interface and AddOns 3 05/31/07 2:48 PM
Bash'ir Landing event in BEM Pater Public Discussion 36 05/30/07 6:28 AM