Trying to get this to work for Mana

I’m trying to get this code to work for units that have mana.
I was able to show power on my own but I’m having a hard time understanding how to add just for mana. I messed around with the code a bit doing some research but no luck.

local spinner3 = CreateSpinner(UIParent)
spinner3:SetFrameLevel(0)
spinner3:SetSize(100, 100)
spinner3:SetPoint('CENTER', TargetFrame.TargetFrameContainer.Portrait)
spinner3:SetTexture("Interface\\Masks\\CircleMaskScalable")
spinner3:SetVertexColor(1, 1, 1)
spinner3:SetClockwise(true)
spinner3:SetReverse(false)
spinner3:Hide()

local Mana = UnitPower("target", Enum.PowerType.Mana)
spinner3:RegisterUnitEvent("UNIT_POWER_UPDATE", Enum.PowerType, target)
spinner3:RegisterEvent("PLAYER_TARGET_CHANGED")
spinner3:SetScript("OnEvent", function(self, event, ...)
	if event == "PLAYER_TARGET_CHANGED" then
		if not UnitExists("target") then
			spinner3:Hide()
			return
		end
		spinner3:Show()
	end
	Mana = UnitPower("target" , Enum.PowerType.Mana)
	local p = Mana
	spinner3:SetValue(p)
end)

If it’s just mana users only to display then more like:

spinner3:RegisterUnitEvent("UNIT_POWER_UPDATE", "target")
spinner3:RegisterEvent("PLAYER_TARGET_CHANGED")
spinner3:SetScript("OnEvent", function(self, event, ...)
	if event == "PLAYER_TARGET_CHANGED" then
		if not UnitExists("target") then
			spinner3:Hide()
			return
		end
		spinner3:Show()
	end
	local mana = UnitPower("target", Enum.PowerType.Mana)
	if not mana or mana == 0 then
		spinner3:SetValue(0)
		return
	end
	local manaMax = UnitPowerMax("target", Enum.PowerType.Mana)
	spinner3:SetValue(mana / manaMax)
end)

Well I’m glad to know I had Enum,PowerType.Mana right at least lol. I was also thinking about (mana/ manaMax) but didn’t think that would work for some reason but the if not mana or mana == 0 I wouldn’t have figured it out on my own for sure. I appreciate Fizz!

Hey Fizz since you’re here I was also trying to change where the start and end angles are on the spinners instead of it ending or starting directly on top but I know not to change the math part because it will affect all the spinners at once.
Is there a way to add that in for each spinner? For example I would put the start and end angle in-between where the tail and head of the dragon is for power.
There’s no rush Fizz I know this is a pretty big project I been at it since 10am this morning lol.

Just to let you know for the future the only other things I’m planning to do is have the power ring class colored and see if it’s possible to make the animation run more smoothly for the spinners. But that’s for later I’m still just adding in everything here.

Thank you for helping me out with the mana code Fizz! This will help me finish up the target frame except for the start and end angles but I can start moving along to the player frame after this and get that all in place.

Getting really close to almost done. This stuff takes a lot of time to get it right.

I certainly don’t have the math for that off the top of my head and I’m not sure the setup really allows for it. If you go back to the original thread I’m pretty sure Semlar had a method for partial ring display so maybe something’s buried there.

Okay I have everything lined up but just need your help on a few things with the player frame. Just spinner 4.
I tried flipping the texture for power but it’s not letting me do the whole SetTexCoord.
I fixed it by just flipping it on photoshop for now as a new texture. ( I wanted to make it More easy on you less to deal with )
I have health showing and working for player now. (progress)

So now it’s just the background texture for health on the player frame.
The background CenterOverlay texture for Health on the player frame hides and shows behaving the same way as target. ( shows when I click on target and hides be when I click off target )
I must be forgetting something I know it’s something easy probably like a function(self)
but I’m having a hard time trying to figure out that one. I know it was setup for target not player so that’s why it hides or shows on clicking a target still lol.

local spinner4 = CreateSpinner(UIParent)
spinner4:SetPoint('CENTER', PlayerFrame.PlayerFrameContainer.PlayerPortraitMask)
spinner4:SetSize(116, 108)
spinner4:SetTexture("Interface\\Addons\\Images\\Ring_20px")
spinner4:SetVertexColor(0, 1, 0)
spinner4:SetClockwise(false)
spinner4:SetReverse(false)
spinner4:Hide()

spinner4.Background = spinner1:CreateTexture()
spinner4.Background:SetDrawLayer("BACKGROUND", -1)
spinner4.Background:SetSize(155, 142)
spinner4.Background:SetPoint("CENTER", PlayerFrame.PlayerFrameContainer.PlayerPortraitMask)
spinner4.Background:SetTexture("Interface\\Addons\\Images\\FullCircleFrameTwo")



local CenterOverlay = CreateFrame("Frame", nil, spinner4)
CenterOverlay:SetFrameLevel(0)
CenterOverlay:SetSize(100, 100)
CenterOverlay:SetPoint("CENTER", PlayerFrame.PlayerFrameContainer.PlayerPortraitMask)
CenterOverlay.Texture = CenterOverlay:CreateTexture()
CenterOverlay.Texture:SetAllPoints()
CenterOverlay.Texture:SetTexture("Interface\\Masks\\CircleMaskScalable")
CenterOverlay.Texture:SetVertexColor(0, 0, 0)

local healthmax = 0
local health = 0
spinner4:RegisterUnitEvent("UNIT_HEALTH", player)
spinner4:RegisterEvent("PLAYER_ENTERING_WORLD")
spinner4:SetScript("OnEvent", function(self, event, ...)
   if event == "PLAYER_ENTERING_WORLD" then
   	if not UnitExists("player") then
   		spinner6:Show()
   		return
   	end
   	spinner4:Show()
   end
   healthmax = UnitHealthMax("player")
   health = UnitHealth("player")
   local h = health / healthmax
   spinner4:SetValue(h)
end)

local spinner5 = CreateSpinner(UIParent)
spinner5:SetPoint('CENTER', PlayerFrame.PlayerFrameContainer.PlayerPortraitMask)
spinner5:SetSize(158, 148)
spinner5:SetTexture("Interface\\Addons\\Images\\DragonCircleBackgroundPlayer")
spinner5:SetVertexColor(1, 1, 1)
spinner5:SetClockwise(true)
spinner5:SetReverse(false)
spinner5:Hide()

local powermax = 0
local power = 0
spinner5:RegisterUnitEvent("UNIT_POWER_FREQUENT", player)
spinner5:RegisterEvent("PLAYER_ENTERING_WORLD")
spinner5:SetScript("OnEvent", function(self, event, ...)
   if event == "PLAYER_ENTERING_WORLD" then
   	if not UnitExists("player") then
   		spinner5:Hide()
   		return
   	end
   	spinner5:Show()
   end
   powermax = UnitPowerMax("player")
   power = UnitPower("player")
   local p = power / powermax
   spinner5:SetValue(p)
end)

local spinner6 = CreateSpinner(UIParent)
spinner6:SetFrameLevel(1)
spinner6:SetSize(90, 90)
spinner6:SetPoint('CENTER', PlayerFrame.PlayerFrameContainer.PlayerPortraitMask)
spinner6:SetTexture("Interface\\Masks\\CircleMaskScalable")
spinner6:SetVertexColor(0.2, 0.2, 0.8)
spinner6:SetClockwise(true)
spinner6:SetReverse(false)
spinner6:Hide()
local manamax = 0
local mana = 0
spinner6:RegisterUnitEvent("UNIT_POWER_UPDATE", "player")
spinner6:RegisterEvent("PLAYER_ENTERING_WORLD")
spinner6:SetScript("OnEvent", function(self, event, ...)
   if event == "PLAYER_ENTERING_WORLD" then
   	if not UnitExists("player") then
   		spinner6:Hide()
   		return
   	end
   	spinner6:Show()
   end
   local mana = UnitPower("player", Enum.PowerType.Mana)
   if not mana or mana == 0 then
   	spinner6:SetValue(0)
   	return
   end
   local manaMax = UnitPowerMax("player", Enum.PowerType.Mana)
   spinner6:SetValue(mana / manaMax)
end)
I almost have it I changed the basic stuff for the player frame the best I could to make it easy... I hope lol `(https://imgur.com/a/ocrOHSr)`
And that's a link to some pics describing what's going on with the code.
Target frame is working pretty well though :grin: