UnitInCombat

UnitInCombat

26.7k Downloads

Filter out friendly nameplates possible?

roanaes opened this issue ยท 13 comments

commented

Hi, first of all love the addon and thanks for creating it!

I noticed you haven't updated the addon in years and I assume you're no longer updating it, but thought I would try anyways.
Do you know if it is possible to filter out friendly nameplates from showing the combat indicator icon and would you like to try add this feature perhaps? Hope it's not already implemented and I just couldn't figure it out :D

In any case loving the addon!

commented

Hey! Thanks for such a quick response and sorry I wasn't able to reply faster. Unfortunately though this doesn't seem to fix it, but I appreciate you caring enough to try! If you want to look more into it that's amazing, but I understand if you don't have time for it since you seem to have much newer and larger projects =)

commented

`can you post your complete file?

commented

Also don't worry, i got some spare time to spare ๐Ÿ˜„

commented

I found the issue,

Change this

function UnitInCombat.HideFrame(frame)
if frame.UnitInCombat["Combat"] and frame.UnitInCombat["Combat"]:IsShown() then
frame.UnitInCombat["Combat"]:Hide()
end
if frame.UnitInCombat["OutOfCombat"] and frame.UnitInCombat["OutOfCombat"]:IsShown() then
frame.UnitInCombat["OutOfCombat"]:Hide()
end
end

To this

function UnitInCombat.HideFrame(frame)
If frame.UnitInCombat then
if frame.UnitInCombat["Combat"] and frame.UnitInCombat["Combat"]:IsShown() then
frame.UnitInCombat["Combat"]:Hide()
end
if frame.UnitInCombat["OutOfCombat"] and frame.UnitInCombat["OutOfCombat"]:IsShown() then
frame.UnitInCombat["OutOfCombat"]:Hide()
end
end
end

Also the two comments you questioned are intended.
Let me know if it works now

commented

Yes it seems to be functioning with no errors now based on quick arena skirmish! Very cool indeed and thank you so much man!!!! Do you have paypal or smth similiar for donations? I can't donate right now but I would like to give a small tip when I get money haha

commented

Nice. I don't have a PayPal but I am happy i could help :)

commented

Your goal was to only show icons on enemy nameplates? If yes it for sure should work with the changes. Did you edit the lua file, save it and reload the UI? Do you have lua errors in wow enabled?

commented

I don't have them enabled, but I'll try and see what they say! and yes that was my goal. And yes that is exactly what I did. I will send screenshots in two minutes!

commented

I enabled LUA errors display, here is what I got:

Message: Interface\AddOns\UnitInCombat\UnitInCombat.lua:171: Usage: UnitIsEnemy("unit", "otherUnit")
Time: Mon Dec  7 20:59:05 2020
Count: 8
Stack: Interface\AddOns\UnitInCombat\UnitInCombat.lua:171: Usage: UnitIsEnemy("unit", "otherUnit")
[string "=[C]"]: ?
[string "=[C]"]: in function `UnitIsEnemy'
[string "@Interface\AddOns\UnitInCombat\UnitInCombat.lua"]:171: in function `?'
[string "@Interface\AddOns\UnitInCombat\UnitInCombat.lua"]:10: in function <Interface\AddOns\UnitInCombat\UnitInCombat.lua:9>

Locals: 
Message: Interface\AddOns\UnitInCombat\UnitInCombat.lua:138: attempt to index field 'UnitInCombat' (a nil value)
Time: Mon Dec  7 21:08:18 2020
Count: 3
Stack: Interface\AddOns\UnitInCombat\UnitInCombat.lua:138: attempt to index field 'UnitInCombat' (a nil value)
[string "=[C]"]: ?
[string "@Interface\AddOns\UnitInCombat\UnitInCombat.lua"]:138: in function `HideFrame'
[string "@Interface\AddOns\UnitInCombat\UnitInCombat.lua"]:182: in function `?'
[string "@Interface\AddOns\UnitInCombat\UnitInCombat.lua"]:10: in function <Interface\AddOns\UnitInCombat\UnitInCombat.lua:9>

Locals: 

and here is screenshot of the edit:
unitincombat1

edit: sorry pasted same error twice before!

commented

Oops, my bad, change it like this

function UnitInCombat.handlerFrame.NAME_PLATE_UNIT_ADDED(unitID)
If UnitIsEnemy("player", unitID) then
local nameplate = C_NamePlate.GetNamePlateForUnit(unitID)--returns table
local nameplatename = nameplate:GetName()
UnitInCombat.VisibleFrames[nameplatename] = unitID
UnitInCombat.CreateIconFrameFor(nameplate, "NamePlate")
end
end

commented

Still getting this:

Message: Interface\AddOns\UnitInCombat\UnitInCombat.lua:138: attempt to index field 'UnitInCombat' (a nil value)
Time: Mon Dec  7 21:31:13 2020
Count: 5
Stack: Interface\AddOns\UnitInCombat\UnitInCombat.lua:138: attempt to index field 'UnitInCombat' (a nil value)
[string "=[C]"]: ?
[string "@Interface\AddOns\UnitInCombat\UnitInCombat.lua"]:138: in function `HideFrame'
[string "@Interface\AddOns\UnitInCombat\UnitInCombat.lua"]:189: in function `?'
[string "@Interface\AddOns\UnitInCombat\UnitInCombat.lua"]:10: in function <Interface\AddOns\UnitInCombat\UnitInCombat.lua:9>

Locals: 

I'm very grateful you are taking the time to try fix this for me even though you wouldn't have to! But I hope it's not bothering you and there is no rush for it!

commented

Hmm I noticed some options were commented out, maybe it doesn't make a difference for this, but here's the options that were commented out

	--CompactRaidFrame	= true, --CompactRaidFrameX, where X is a number, is created dynamically
	--NamePlate 		= true, -created dynamically

and here are the errors I get if I uncomment the above lines with the modified code:

Message: Interface\AddOns\UnitInCombat\UnitInCombat.lua:236: 'for' limit must be a number
Time: Mon Dec  7 21:37:27 2020
Count: 1
Stack: Interface\AddOns\UnitInCombat\UnitInCombat.lua:236: 'for' limit must be a number
[string "=[C]"]: ?
[string "@Interface\AddOns\UnitInCombat\UnitInCombat.lua"]:236: in main chunk

Locals: 
Message: (null)
Time: Mon Dec  7 21:37:29 2020
Count: 3
Message: Interface\AddOns\UnitInCombat\UnitInCombat.lua:138: attempt to index field 'UnitInCombat' (a nil value)
Time: Mon Dec  7 21:39:27 2020
Count: 13
Stack: Interface\AddOns\UnitInCombat\UnitInCombat.lua:138: attempt to index field 'UnitInCombat' (a nil value)
[string "=[C]"]: ?
[string "@Interface\AddOns\UnitInCombat\UnitInCombat.lua"]:138: in function `HideFrame'
[string "@Interface\AddOns\UnitInCombat\UnitInCombat.lua"]:182: in function `?'
[string "@Interface\AddOns\UnitInCombat\UnitInCombat.lua"]:10: in function <Interface\AddOns\UnitInCombat\UnitInCombat.lua:9>

Locals: 
commented

Hey, thanks for liking the addon. Sure, nothing is impossible.
It's pretty easy to only show it for enemies,

Just replace the function

function UnitInCombat.handlerFrame.NAME_PLATE_UNIT_ADDED(unitID)
local nameplate = C_NamePlate.GetNamePlateForUnit(unitID)--returns table
local nameplatename = nameplate:GetName()
UnitInCombat.VisibleFrames[nameplatename] = unitID
UnitInCombat.CreateIconFrameFor(nameplate, "NamePlate")
end

With this

function UnitInCombat.handlerFrame.NAME_PLATE_UNIT_ADDED(unitID)
If UnitIsEnemy(unitID) then
local nameplate = C_NamePlate.GetNamePlateForUnit(unitID)--returns table
local nameplatename = nameplate:GetName()
UnitInCombat.VisibleFrames[nameplatename] = unitID
UnitInCombat.CreateIconFrameFor(nameplate, "NamePlate")
end
end

I hope it works for you, i did it quickly on the phone and the indentation is probably a bit off