oUF

99.9k Downloads

PVP indicator issue

fafaraway opened this issue ยท 3 comments

commented

use these code to create pvp indicator for a long time, works fine

local PvPIndicator = F.CreateFS(self)
PvPIndicator:SetPoint("BOTTOMRIGHT", Health, "TOPRIGHT", -50, 3)
PvPIndicator:SetText("P")
PvPIndicator:SetTextColor(1, 0, 0)
self.PvPIndicator = PvPIndicator

but since update to ouf 8.0, keep getting this error, any idea to fix this?

...ddOns\FreeUI\libraries\oUF\elements\pvpindicator.lua:80: attempt to call method 'SetTexture' (a nil value)
Count: 3
Call Stack:
[C]: in function "SetTexture"
...ddOns\FreeUI\libraries\oUF\elements\pvpindicator.lua:80: in function <...ddOns\FreeUI\libraries\oUF\elements\pvpindicator.lua:38>
(tail call): ?
Interface\AddOns\FreeUI\libraries\oUF\ouf.lua:211: in function <Interface\AddOns\FreeUI\libraries\oUF\ouf.lua:200>
(tail call): ?

commented

From the docs in pvpindicator.lua.

# Element: PvP and Honor Level Icons

Handles the visibility and updating of an indicator based on the unit's PvP status and honor level.

## Widget

PvPIndicator - A `Texture` used to display faction, FFA PvP status or honor level icon.

## Sub-Widgets

Badge - A `Texture` used to display the honor badge background image.

.PvPIndicator is supposed to be a texture, but you're creating a font string, in your case you should also use .Override to override internal update process.

On a side note, you couldn't use font strings w/o .Override in oUF 7.x.x either. It's always expecting a texture.

commented

Alternatively you can just noop the new texture functions oUF uses and use it like before:

local noop = function() end
PvPIndicator.SetTexture = noop
PvPIndicator.SetTexCoord = noop

Or just use tags instead.

commented

hey ls haste, thanks for explain, really appreciate it.
I totally forgot update and override part ๐Ÿ˜†
Now it works, thanks again.

local PvPIndicator = F.CreateFS(self)
PvPIndicator:SetPoint("BOTTOMRIGHT", Health, "TOPRIGHT", -50, 3)
PvPIndicator:SetText("P")

		`local UpdatePvPIndicator = function(self, event, unit)`
			`if(unit ~= self.unit) then return end`

			`local PvPIndicator = self.PvPIndicator`

			`local factionGroup = UnitFactionGroup(unit)`
			`if(UnitIsPVPFreeForAll(unit) or (factionGroup and factionGroup ~= "Neutral" and UnitIsPVP(unit))) then`
				`if factionGroup == "Alliance" then`
					`PvPIndicator:SetTextColor(0, 0.68, 0.94)`
				`else`
					`PvPIndicator:SetTextColor(1, 0, 0)`
				`end`

				`PvPIndicator:Show()`
			`else`
				`PvPIndicator:Hide()`
			`end`
		`end`

		`self.PvPIndicator = PvPIndicator`
		`PvPIndicator.Override = UpdatePvPIndicator`