Anyone with a WeakAura that can see how many players that is on that target?
Anyone with a WeakAura that can see how many players that is on that target?
Make a trigger that suits you, type "%c" in the output's text field, make it update on every frame (not "trigger update") and use this as a custom code function:
Guess the trigger that would suit you is "Status - Conditions - Always true" with "In combat" as a loading option.Code:if not aura_env.lastCheck then aura_env.lastCheck = 0 end if not aura_env.value then aura_env.value = "" end local curTime = GetTime() if (curTime - aura_env.lastCheck) > 0.2 then -- update every 0.2 secs rather than every frame aura_env.lastCheck = curTime if UnitExists("target") then -- if we have no target then why bother local groupType = IsInRaid() and "raid" or IsInGroup() and "party" or nil if not groupType then -- if we are not in a group then why bother aura_env.value = "" else local players = GetNumGroupMembers() local temp local targetedBy = 0 for i = 1, players do temp = string.format("%s%dtarget", groupType, i) -- raid1target, raid2target, raid3target and so on if UnitIsUnit("target", temp) then targetedBy = targetedBy + 1 end end aura_env.value = tostring(targetedBy) end end end return aura_env.value
Should work, but I didn't test.
Rather than an OnUpdate script you should use the event UNIT_TARGET to trigger the scan anytime a unit in the raid/party/instance, or your target/focus/ToT, changes target.
I will say this now, the code was not tested.
Code:local number = "" -- just in case if UnitExists("target") then -- if we have no target then why bother number = 0 local targetID = UnitGUID('target') -- your targets GUID local groupType = IsInRaid() and "raid" or IsInGroup() and "party" or nil if groupType then -- if we are in a group then we bother for i = 1, GetNumGroupMembers() do -- funny thing, this isn't Javascript; it calls the function once in Lua. if targetID == UnitGUID(string.format("%s%dtarget", groupType, i)) then number = number + 1 end end number = tostring(number) end end return number
"I have not failed, I simply found 10,000 ways that did not work." - Thomas Edison
I have this done for myself (working only in raid by pressing shift key)
trigger > custom > status > events > MODIFIER_STATE_CHANGED
CUSTOM TRIGGER
CUSTOM UNTRIGGERCode:function(event, key, state) if key == "LSHIFT" or key == "RSHIFT" then return state == 1 end end
DISPLAY > %cCode:function(event, key, state) if key == "LSHIFT" or key == "RSHIFT" then -- If it was one of the shift keys that changed, return state == 0 -- Then hide if the state is 0 (i.e. the key was released) end end
Code:function() local names = "" local pt = UnitGUID("playertarget") if not pt then return "" end local counter = 0 local amount = 0 for i=1, GetNumGroupMembers() do local raider = "raid"..i.."target" if UnitGUID(raider) == pt then local name = UnitName("raid"..i) if name then local _,class = UnitClass("raid"..i) local colorText = RAID_CLASS_COLORS[class] and RAID_CLASS_COLORS[class].colorStr or "ffbbbbbb" names = names .. (counter > 0 and ", " or "") .. "\124c" .. colorText .. name .. "\124r" counter = counter + 1 amount = amount + 1 if counter > 4 then names = names .. "\124n" counter = 0 end end end end return amount..": "..names end
I thought about that but the last time I tried UNIT_TARGET, it was a bit delayed. But if you're ok with that, or it's just something only I experience, that's clearly a better solution, because it's more efficient.
Alright, alright. It was just a "better safe than sorry" policy. I have nothing to do with Javascript though.
I actually like Translit's approach: show it only when you want it to be shown.
Though, I am being genuinely curious, why do you guys compare results of UnitGUID() instead of just using UnitIsUnit()? Is there something wrong with the latter?
I have been working with Javascript recently and the similarities between it and Lua are scary. That just so happened to be one of the things I disliked about Javascript that I wanted to point it out. Like a big middle finger to Javascript... since my update to Windows 10 deleted my projects.
The modifier approach is also good. Have not personally used that approach myself but one can never go wrong with button press triggering things.
My choice of comparing GUID is preference but UnitIsUnit will work just as well.
"I have not failed, I simply found 10,000 ways that did not work." - Thomas Edison
If you are using ElvUI / TukUI there is an plugin to do just this. It displays the number of people targeting your current target, and also how many is targeting your mouseover targets if you will. The plugin is called Shadow and Light. It also comes with a bunch of other really good tools that complement the already added awesome-ness of ElvUI.
http://www.curse.com/addons/wow/shadow-and-light-edit