Hi there,
I am currently developing my new orb system.
http://www.wowinterface.com/downloads/info11008.html
I use a function to create every orb and on given events I will update or hide/show that specific orb.
Its very dynamic and you can create as many orbs as you want.
I looked into the Blizzard UI to find out the event for the TargetofTarget change. To my suprise there is none.
Currently my orb system handles player and target orbs just fine. The next step is to add orbs that could be of the type pet, focus and targettarget.
I checked the Blizzard code and found out that they check the TargetofTarget with a OnUpdate script. I don't want to do that if I don't have to.
Patch 2.0.x introduced a new Event the UNIT_TARGET Event.
This is the script for my red orbs that I am using currently:
Code:
f:SetScript("OnEvent", function(frame, event, unit)
if event == "UNIT_HEALTH" and unit == unitid then
--do stuff
elseif event == "PLAYER_ENTERING_WORLD" then
--do stuff
elseif event == "PLAYER_LOGIN" then
--do stuff
elseif event == "PLAYER_TARGET_CHANGED" and unitid == "target" then
if(UnitExists(unitid)) then
f:Show()
f3:Show()
--do stuff
--DEFAULT_CHAT_FRAME:AddMessage("1 "..unitid)
else
f:Hide()
f3:Hide()
--DEFAULT_CHAT_FRAME:AddMessage("2 "..unitid)
end
end
end)
f:RegisterEvent("UNIT_HEALTH")
f:RegisterEvent("PLAYER_ENTERING_WORLD")
f:RegisterEvent("PLAYER_LOGIN")
f:RegisterEvent("PLAYER_TARGET_CHANGED")
It works just fine and now I want to add one condition for the targettarget.
UNIT_TARGET will be fired if the target of a primary unit changes. My guess is that unit "target" is one of this primary units. So I could take it as a base.
My guess is, if I track for the Event UNIT_TARGET and it is fired and my arg1 is "target" I could do a UnitExists-Check for targettarget.
I would change my Script to sth like this:
Code:
f:SetScript("OnEvent", function(frame, event, unit, arg1)
if event == "UNIT_HEALTH" and unit == unitid then
--do stuff
elseif event == "PLAYER_ENTERING_WORLD" then
--do stuff
elseif event == "PLAYER_LOGIN" then
--do stuff
elseif event == "PLAYER_TARGET_CHANGED" and unitid == "target" then
if(UnitExists(unitid)) then
f:Show()
f3:Show()
--do stuff
--DEFAULT_CHAT_FRAME:AddMessage("1 "..unitid)
else
f:Hide()
f3:Hide()
--DEFAULT_CHAT_FRAME:AddMessage("2 "..unitid)
end
elseif event == "UNIT_TARGET" and arg1 == "target" and unitid == "targettarget" then
if(UnitExists(unitid)) then
f:Show()
f3:Show()
--do stuff
--DEFAULT_CHAT_FRAME:AddMessage("1 "..unitid)
else
f:Hide()
f3:Hide()
--DEFAULT_CHAT_FRAME:AddMessage("2 "..unitid)
end
end
end)
f:RegisterEvent("UNIT_HEALTH")
f:RegisterEvent("PLAYER_ENTERING_WORLD")
f:RegisterEvent("PLAYER_LOGIN")
f:RegisterEvent("PLAYER_TARGET_CHANGED")
f:RegisterEvent("UNIT_TARGET")
What do you think?