Thread Tools Display Modes
09-23-18, 08:15 PM   #1
superfula
A Deviate Faerie Dragon
Join Date: Mar 2006
Posts: 14
Azerite tooltip throwing error when mousing over azerite bar

I'm working on a bar addon that is supposed to place an xp/rep bar below the minimap and then an azerite bar just below that. I am able to get both bars to show, however I'm down to one last issue. The azerite tooltip that should show when you mouseover the azerite bar gives this error:

Code:
30x modules/exp.lua:255: bad argument #1 to 'format' (string expected, got nil)
[C]: in function `format'
modules/exp.lua:255: in function <modules/exp.lua:248>
modules/exp.lua:280: in function <modules/exp.lua:280>

Locals:
(*temporary) = "Level %s (%s Artifact Power to next level)"
(*temporary) = nil
(*temporary) = nil
(*temporary) = "string expected, got nil"
Full addon code.

Code:
local SCALE			= 1
--local WIDTH 			= 348
local WIDTH 		= 236
local HEIGHT 		= 4
local _, CLASS 		= UnitClass('player')
local COLOR			= CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS[CLASS] or RAID_CLASS_COLORS[CLASS]
--local POSITION		= {'CENTER', UIParent, 'BOTTOM', 0, 4}
local POSITION		= {'TOP', Minimap, 'BOTTOM', 0, 17}
local OFFSET		= -13
--local TIP				= {'TOPRIGHT', UIParent, -275, -235}
local TIP			= {'TOPRIGHT', UIParent, -275, -235}
local TEXTURE 		= [[Interface\AddOns\LynExperience\assets\statusbar]]
local CLASSCOLOR 	= CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS[CLASS] or RAID_CLASS_COLORS[CLASS]

f = CreateFrame('Frame', nil, UIParent)
f:SetPoint(POSITION[1], POSITION[2], POSITION[3], POSITION[4], POSITION[5])
f:SetWidth(WIDTH)
f:SetHeight(HEIGHT)
f:SetScale(SCALE)

-- SETUP BARS
local setBar = function(frame)
	frame:SetStatusBarTexture(TEXTURE)
	frame:SetWidth(WIDTH)
	frame:SetHeight(HEIGHT)
	frame:SetScale(SCALE)
end

local setBackdrop = function(frame)
	frame.bg = CreateFrame('Frame', nil, frame)
	frame.bg:SetBackdrop({
		bgFile = [[Interface/Buttons/WHITE8X8]],
		tiled = false,
		insets = {left = 0, right = 0, top = 0, bottom = 0}
	})
	frame.bg:SetPoint('TOPLEFT', frame, 0, 0)
	frame.bg:SetPoint('BOTTOMRIGHT', frame, 0, 0)
	frame.bg:SetFrameLevel(1)
	frame.bg:SetBackdropColor(0, 0, 0, 0.2)

	frame.shadow = CreateFrame('Frame', nil, frame)
	frame.shadow:SetBackdrop({
		bgFile = [[Interface\Tooltips\UI-Tooltip-Background]],
		tiled = false,
		insets = {left = 0, right = 0, top = 0, bottom = 0}
	})
	frame.shadow:SetPoint('TOPLEFT', frame, -3, 3)
	frame.shadow:SetPoint('BOTTOMRIGHT', frame, 3, -3)
	frame.shadow:SetFrameLevel(0)
	frame.shadow:SetBackdropColor(0, 0, 0, 0)
end

local exp = CreateFrame('StatusBar', nil, f, 'AnimatedStatusBarTemplate')
setBar(exp)
exp:SetFrameLevel(4)
exp:SetStatusBarColor(.4, .1, .6)
exp:SetAnimatedTextureColors(.4, .1, .6)
exp:SetPoint(POSITION[1], POSITION[2], POSITION[3], POSITION[4], POSITION[5])
setBackdrop(exp)

local rest = CreateFrame('StatusBar', nil, xp)
setBar(rest)
rest:SetFrameLevel(3)
rest:EnableMouse(false)
rest:SetStatusBarColor(.2, .4, .8)
rest:SetAllPoints(exp)

local azerite = CreateFrame('StatusBar', nil, f, 'AnimatedStatusBarTemplate')
setBar(azerite)
azerite:SetFrameLevel(4)
azerite:SetStatusBarColor(.9, .8, .6)
azerite:SetAnimatedTextureColors(.9, .8, .6)
azerite:SetPoint(POSITION[1], POSITION[2], POSITION[3], POSITION[4], POSITION[5] + OFFSET)
setBackdrop(azerite)

-- DATA METHODS
local factionStanding = {
	[1] = { name = 'Hated' },
	[2] = { name = 'Hostile' },
	[3] = { name = 'Unfriendly' },
	[4] = { name = 'Neutral' },
	[5] = { name = 'Friendly' },
	[6] = { name = 'Honored' },
	[7] = { name = 'Revered' },
	[8] = { name = 'Exalted' },
};

local numberize = function(v)
    if v <= 9999 then return v end
    if v >= 1000000 then
        local value = string.format('%.1fm', v/1000000)
        return value
    elseif v >= 10000 then
        local value = string.format('%.1fk', v/1000)
        return value
    end
end


local exp_update = function()
	if UnitLevel('player') == MAX_PLAYER_LEVEL then
		local name, standing, min, max, cur = GetWatchedFactionInfo()
		if name then
			local faction = FACTION_BAR_COLORS[standing]
			exp:SetStatusBarColor(faction.r, faction.g, faction.b)
			exp:SetAnimatedTextureColors(faction.r, faction.g, faction.b)
			--print(cur, min, max, cur-min, 0, max-min)
			exp:SetAnimatedValues(cur - min, 0, max - min, standing)
			-- xp:SetMinMaxValues(min, max)
			-- xp:SetValue(cur)

			rest:SetMinMaxValues(0, 1)
			rest:SetValue(0)

			exp:Show()
			rest:Show()
			return
		end

		--xp:SetAnimatedValues(0, 0, 1, 1)
		exp:Hide()
		rest:Hide()
		--rest:SetMinMaxValues(0, 1)
		--rest:SetValue(0)
	else
		local c, m, l	= UnitXP('player'), UnitXPMax('player'), UnitLevel('player')
		local p 			= math.ceil(c/m*100)
		local r			= GetXPExhaustion()

		exp:SetAnimatedValues(c, 0, m, l)
		-- xp:SetMinMaxValues(min(0, c), m)
		-- xp:SetValue(c)
		rest:SetMinMaxValues(min(0, c), m)
		rest:SetValue(r and (c + r) or 0)

		exp:Show()
		rest:Show()
	end
end

local showExperienceTooltip = function(self)
	if UnitLevel('player') == MAX_PLAYER_LEVEL then
		local name, standing, min, max, cur = GetWatchedFactionInfo()
		if name then
			local faction = FACTION_BAR_COLORS[standing]

			GameTooltip:SetOwner(self, 'ANCHOR_NONE')
			GameTooltip:SetPoint(TIP[1], TIP[2], TIP[3], TIP[4], TIP[5])

			GameTooltip:AddLine(name, faction.r, faction.g, faction.b)
			GameTooltip:AddLine(factionStanding[standing].name, 1, 1, 1)
			GameTooltip:AddLine(cur-min.."/"..max-min, 1, 1, 1)

			GameTooltip:Show()
		end
	else
		local xpc, xpm, xpr = UnitXP('player'), UnitXPMax('player'), GetXPExhaustion('player')

		GameTooltip:SetOwner(self, 'ANCHOR_NONE')
		GameTooltip:SetPoint(TIP[1], TIP[2], TIP[3], TIP[4], TIP[5])

		GameTooltip:AddLine('Level '..UnitLevel('player'), COLOR.r, COLOR.g, COLOR.b)
		GameTooltip:AddLine((numberize(xpc)..'/'..numberize(xpm)..' ('..floor((xpc/xpm)*100) ..'%)'), 1, 1, 1)
		if xpr then
			GameTooltip:AddLine(numberize(xpr)..' ('..floor((xpr/xpm)*100) ..'%)', .2, .4, .8)
		end

		GameTooltip:Show()
	end
end

local azerite_update = function(self)
local azeriteItemLocation = C_AzeriteItem.FindActiveAzeriteItem()
--if C_AzeriteItem.HasActiveAzeriteItem() then

	if azeriteItemLocation then
		--local azeriteItem = Item:CreateFromItemLocation(azeriteItemLocation);
		--local azeriteItemName = azeriteItem:GetItemName()

		local xp, totalLevelXP = C_AzeriteItem.GetAzeriteItemXPInfo(azeriteItemLocation)
		local currentLevel = C_AzeriteItem.GetPowerLevel(azeriteItemLocation)
		local xpToNextLevel = totalLevelXP - xp
		
		if not azerite:IsShown() then
			azerite:Show()
		end

		azerite:SetAnimatedValues(xp, 0, totalLevelXP)
--		azerite:SetMinMaxValues(0, totalLevelXP)
--		azerite:SetValue(xp)
--		azerite:Show()

--		local y
--		if UnitLevel'player' < MAX_PLAYER_LEVEL or faction then
--			y = POSITION[5] + OFFSET
--		else
--			y = POSITION[5]
--		end
--		
--		azerite:SetPoint(POSITION[1], POSITION[2], POSITION[3], POSITION[4], y)
	else
		if azerite:IsShown() then
			azerite:Hide()
		end
	end
	if event == 'AZERITE_ITEM_EXPERIENCE_CHANGED' or event == 'PLAYER_ENTERING_WORLD' then
		if not azerite:IsShown() then
			azerite:Show()
		end
	end
end
		


local showAzeriteTooltip = function(self)
	local azeriteItemLocation = C_AzeriteItem.FindActiveAzeriteItem();
	local azeriteItem = Item:CreateFromItemLocation(azeriteItemLocation);
    local azeriteItemName = azeriteItem:GetItemName();
	
	GameTooltip:SetOwner(self, 'ANCHOR_NONE')
	GameTooltip:SetPoint(TIP[1], TIP[2], TIP[3], TIP[4], TIP[5])
	GameTooltip:SetText(AZERITE_POWER_TOOLTIP_TITLE:format(currentLevel, xpToNextLevel), HIGHLIGHT_FONT_COLOR:GetRGB());
    GameTooltip:AddLine(AZERITE_POWER_TOOLTIP_BODY:format(azeriteItemName));

	GameTooltip:Show()
end

-- events
exp:RegisterEvent('PLAYER_LEVEL_UP')
exp:RegisterEvent('PLAYER_XP_UPDATE')
exp:RegisterEvent('UPDATE_EXHAUSTION')
exp:RegisterEvent('PLAYER_ENTERING_WORLD')
exp:RegisterEvent('MODIFIER_STATE_CHANGED')
exp:RegisterEvent('UPDATE_FACTION')
exp:RegisterEvent('ADDON_LOADED')
exp:SetScript('OnEvent', exp_update)
exp:SetScript('OnEnter', function() showExperienceTooltip(exp) end)
exp:SetScript('OnLeave', function() GameTooltip:Hide() end)

azerite:RegisterEvent('PLAYER_ENTERING_WORLD')
azerite:RegisterEvent('AZERITE_ITEM_EXPERIENCE_CHANGED')
azerite:RegisterEvent('PLAYER_EQUIPMENT_CHANGED')
azerite:RegisterEvent('PLAYER_LEVEL_UP')
azerite:RegisterEvent('UPDATE_FACTION')
azerite:RegisterEvent('ADDON_LOADED')
azerite:SetScript('OnEvent', azerite_update)
azerite:SetScript('OnEnter', function() showAzeriteTooltip(azerite) end)
azerite:SetScript('OnLeave', function() GameTooltip:Hide() end)

hooksecurefunc("SetWatchedFactionIndex", function(self)
	exp_update()
    azerite_update()
end)

Last edited by superfula : 09-27-18 at 03:20 PM.
  Reply With Quote
09-23-18, 08:39 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
Bar HEIGHT is 4
Bar y pos is CENTER, UIParent, BOTTOM,0, 4-13

I get the feeling it's below the bottom of the screen.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
09-23-18, 08:44 PM   #3
superfula
A Deviate Faerie Dragon
Join Date: Mar 2006
Posts: 14
Originally Posted by Fizzlemizz View Post
Bar HEIGHT is 4
Bar y pos is CENTER, UIParent, BOTTOM,0, 4-13

I get the feeling it's below the bottom of the screen.
That location is commented out. The location of the xp bar, which shows fine, is TOP', Minimap, 'BOTTOM', 0, 17. Then the azerite bar should be -13 below that.
  Reply With Quote
09-23-18, 10:00 PM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
Code:
local azeriteItemLocation = C_AzeriteItem.FindActiveAzeriteItem()
Have you tested the value of azeriteItemLocation ?
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
09-23-18, 10:31 PM   #5
superfula
A Deviate Faerie Dragon
Join Date: Mar 2006
Posts: 14
Originally Posted by Fizzlemizz View Post
Code:
local azeriteItemLocation = C_AzeriteItem.FindActiveAzeriteItem()
Have you tested the value of azeriteItemLocation ?
I'll admit I'm very much a novice at this so I'm not sure what you mean.
  Reply With Quote
09-24-18, 12:09 AM   #6
superfula
A Deviate Faerie Dragon
Join Date: Mar 2006
Posts: 14
Originally Posted by superfula View Post
I'll admit I'm very much a novice at this so I'm not sure what you mean.
Just a quick update. I managed to get a bar to show however it's a full bar and not a partial like it should be. I'm only 9% into the level right now. Tooltips are working though.

edit: Finally figured it out. I was missing the following lines...

bar:SetMinMaxValues(0, totalLevelXP)
bar:SetValue(xp)
bar:Show()

Last edited by superfula : 09-24-18 at 12:38 AM.
  Reply With Quote
09-26-18, 11:23 PM   #7
superfula
A Deviate Faerie Dragon
Join Date: Mar 2006
Posts: 14
Originally Posted by superfula View Post
Just a quick update. I managed to get a bar to show however it's a full bar and not a partial like it should be. I'm only 9% into the level right now. Tooltips are working though.

edit: Finally figured it out. I was missing the following lines...

bar:SetMinMaxValues(0, totalLevelXP)
bar:SetValue(xp)
bar:Show()
Well I'm still fiddling. The bar won't show properly without a reloadui. I've updated the first post with more info along with my current code.

Last edited by superfula : 09-26-18 at 11:36 PM.
  Reply With Quote
09-27-18, 12:09 AM   #8
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
When it works after a reload it's mostly because you create the object too early in the loading process. Try to delay it until the information is fully available. Player entering world is a good start.
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
09-27-18, 12:28 AM   #9
superfula
A Deviate Faerie Dragon
Join Date: Mar 2006
Posts: 14
Originally Posted by Rilgamon View Post
When it works after a reload it's mostly because you create the object too early in the loading process. Try to delay it until the information is fully available. Player entering world is a good start.
I wondered about that, but I do have this bit of code at the end of where I'm loading the azerite bar:

Code:
if event == 'AZERITE_ITEM_EXPERIENCE_CHANGED' or event == 'PLAYER_ENTERING_WORLD' then
		if not azerite:IsShown() then
			azerite:Show()
		end
end
I tried adding something similar right after my exp/rest section but it didn't load without a reloadui.
  Reply With Quote
09-27-18, 01:31 AM   #10
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
Lua Code:
  1. local azeriteItemLocation = C_AzeriteItem.FindActiveAzeriteItem()
  2.         if (not azeriteItemLocation) then
  3.             return
  4.         end

Your code is a little difficult to read so I'm not 100% sure. But your code above would probably simply stop exactly here and dont execute code listed after that. Try to make your code more modular. So that every part is only accessed when it should.
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
09-27-18, 10:40 AM   #11
superfula
A Deviate Faerie Dragon
Join Date: Mar 2006
Posts: 14
Originally Posted by Rilgamon View Post
Lua Code:
  1. local azeriteItemLocation = C_AzeriteItem.FindActiveAzeriteItem()
  2.         if (not azeriteItemLocation) then
  3.             return
  4.         end

Your code is a little difficult to read so I'm not 100% sure. But your code above would probably simply stop exactly here and dont execute code listed after that. Try to make your code more modular. So that every part is only accessed when it should.
It is a mess. I'm fairly new to Lua so it's a mixture of a previous addon, figuring things out, and borrowing from others.

I pulled that part from https://www.townlong-yak.com/framexm...AzeriteBar.lua so I thought it may be needed. I could be misreading, but I read it as if the code doesn't find an Azerite Item it stops. The large commented section above that was my initial attempt but for some reason the Azerite bar doesn't show at all with that bit of code used instead of what is running now.
  Reply With Quote
09-27-18, 11:15 AM   #12
superfula
A Deviate Faerie Dragon
Join Date: Mar 2006
Posts: 14
Well, for better or worse this is what I have working, with one caveat. Any tips to clean up the code is appreciated. I left the uncommented stuff in for now.

Code:
local azerite_update = function(self)
local azeriteItemLocation = C_AzeriteItem.FindActiveAzeriteItem()
--if C_AzeriteItem.HasActiveAzeriteItem() then

	if azeriteItemLocation then
		--local azeriteItem = Item:CreateFromItemLocation(azeriteItemLocation);
		--local azeriteItemName = azeriteItem:GetItemName()

		local xp, totalLevelXP = C_AzeriteItem.GetAzeriteItemXPInfo(azeriteItemLocation)
		local currentLevel = C_AzeriteItem.GetPowerLevel(azeriteItemLocation)
		local xpToNextLevel = totalLevelXP - xp
		
		if not azerite:IsShown() then
			azerite:Show()
		end

		azerite:SetAnimatedValues(xp, 0, totalLevelXP)
--		azerite:SetMinMaxValues(0, totalLevelXP)
--		azerite:SetValue(xp)
--		azerite:Show()

--		local y
--		if UnitLevel'player' < MAX_PLAYER_LEVEL or faction then
--			y = POSITION[5] + OFFSET
--		else
--			y = POSITION[5]
--		end
--		
--		azerite:SetPoint(POSITION[1], POSITION[2], POSITION[3], POSITION[4], y)
	else
		if azerite:IsShown() then
			azerite:Hide()
		end
	end
	if event == 'AZERITE_ITEM_EXPERIENCE_CHANGED' or event == 'PLAYER_ENTERING_WORLD' then
		if not azerite:IsShown() then
			azerite:Show()
		end
	end
end
The caveat. The azerite tooltip that should show when you mouseover the azerite bar gives this error:

Code:
30x modules/exp.lua:255: bad argument #1 to 'format' (string expected, got nil)
[C]: in function `format'
modules/exp.lua:255: in function <modules/exp.lua:248>
modules/exp.lua:280: in function <modules/exp.lua:280>

Locals:
(*temporary) = "Level %s (%s Artifact Power to next level)"
(*temporary) = nil
(*temporary) = nil
(*temporary) = "string expected, got nil"

Last edited by superfula : 09-27-18 at 03:17 PM.
  Reply With Quote
09-27-18, 04:47 PM   #13
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
On nUI for the tooltip I have this ( plus a few others ) which seems to be similar to what you were trying to display.

Code:
GameTooltip:SetText(
  AZERITE_POWER_TOOLTIP_TITLE:format(level, xpToNextLevel), 
  HIGHLIGHT_FONT_COLOR:GetRGB()
)
For the rest of the code nUI has its own statusbar functionality but it is similar to yours, this is the main block, it only gets executed if the itemLocation is valid.

Code:
    local xp, totalXP = C_AzeriteItem.GetAzeriteItemXPInfo(azeriteItemLocation);
    local currentLevel = C_AzeriteItem.GetPowerLevel(azeriteItemLocation);
    local xpToNextLevel = totalXP - xp;
    local pct = xp / totalXP
I also have this hefty block of code that identifies which azerite items you have and if they have powers not applied and creates the tooltip.

Code:
    frame:SetScript( "OnEnter", 
        function()
            local azeriteItemLocation = C_AzeriteItem.FindActiveAzeriteItem()
            local azeriteItem = azeriteItemLocation and Item:CreateFromItemLocation(azeriteItemLocation) or nil
            local azeriteItemName = azeriteItem and azeriteItem:GetItemName() or nil

            local neckItemLocation = ItemLocation:CreateFromEquipmentSlot(Enum.InventoryType.IndexNeckType)
            local headItemLocation = ItemLocation:CreateFromEquipmentSlot(Enum.InventoryType.IndexHeadType)
            local shoulderItemLocation = ItemLocation:CreateFromEquipmentSlot(Enum.InventoryType.IndexShoulderType)
            local chestItemLocation = ItemLocation:CreateFromEquipmentSlot(Enum.InventoryType.IndexChestType)

            local hasNeckItem = C_Item.DoesItemExist(neckItemLocation)
            local hasHeadItem = C_Item.DoesItemExist(headItemLocation)
            local hasShoulderItem = C_Item.DoesItemExist(shoulderItemLocation)
            local hasChestItem = C_Item.DoesItemExist(chestItemLocation)
            
            local headIsAzeriteEmpowered = hasHeadItem and C_AzeriteEmpoweredItem.IsAzeriteEmpoweredItem(headItemLocation)
            local shoulderIsAzeriteEmpowered = hasShoulderItem and C_AzeriteEmpoweredItem.IsAzeriteEmpoweredItem(shoulderItemLocation)
            local chestIsAzeriteEmpowered = hasChestItem and C_AzeriteEmpoweredItem.IsAzeriteEmpoweredItem(chestItemLocation)

            local headItem = headItemLocation and headIsAzeriteEmpowered and Item:CreateFromItemLocation(headItemLocation) or nil
            local shoulderItem = shoulderItemLocation and shoulderIsAzeriteEmpowered and Item:CreateFromItemLocation(shoulderItemLocation) or nil
            local chestItem = chestItemLocation and chestIsAzeriteEmpowered and Item:CreateFromItemLocation(chestItemLocation) or nil

            local headItemName = headItem and headItem:GetItemName() or ""
            local shoulderItemName = shoulderItem and shoulderItem:GetItemName() or ""
            local chestItemName = chestItem and chestItem:GetItemName() or ""

            local azeritePowerAvailable = " (" .. AZERITE_ITEM_LEVELED_UP_TOAST_UNLOCKED_MULTIPLE .. ")" 

            local headHasPowers = headItem and C_AzeriteEmpoweredItem.HasAnyUnselectedPowers(headItemLocation) and azeritePowerAvailable or ""
            local shoulderHasPowers = shoulderItem and C_AzeriteEmpoweredItem.HasAnyUnselectedPowers(shoulderItemLocation) and azeritePowerAvailable or ""
            local chestHasPowers = chestItem and C_AzeriteEmpoweredItem.HasAnyUnselectedPowers(chestItemLocation) and azeritePowerAvailable or ""

            local isEquippedAzeriteItem = hasNeckItem and (C_Item.GetItemInventoryType(azeriteItemLocation) == Enum.InventoryType.IndexNeckType)
            local mustEquip = (not hasNeckItem or not isEquippedAzeriteItem) and ERR_MUST_EQUIP_ARTIFACT or ""
            
            GameTooltip:SetOwner( frame );
            GameTooltip:ClearLines()
            GameTooltip:SetText(AZERITE_POWER_TOOLTIP_TITLE:format(frame.level, frame.xpToNextLevel), HIGHLIGHT_FONT_COLOR:GetRGB());
            GameTooltip:AddLine(AZERITE_POWER_TOOLTIP_BODY:format(azeriteItemName));
            GameTooltip:AddLine(mustEquip,HIGHLIGHT_FONT_COLOR:GetRGB())
            GameTooltip:AddLine(headItemName .. headHasPowers ,HIGHLIGHT_FONT_COLOR:GetRGB())
            GameTooltip:AddLine(shoulderItemName .. shoulderHasPowers ,HIGHLIGHT_FONT_COLOR:GetRGB())
            GameTooltip:AddLine(chestItemName .. chestHasPowers ,HIGHLIGHT_FONT_COLOR:GetRGB())

            GameTooltip:Show();
        end
    );
__________________
  Reply With Quote
09-29-18, 05:31 AM   #14
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
Lua Code:
  1. local SCALE         = 1
  2. --local WIDTH           = 348
  3. local WIDTH         = 236
  4. local HEIGHT        = 8
  5. local _, CLASS      = UnitClass('player')
  6. local COLOR         = CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS[CLASS] or RAID_CLASS_COLORS[CLASS]
  7. local POSITION      = {'CENTER', UIParent, 'CENTER', 0, 17}
  8. local OFFSET        = -13
  9. local TIP           = {'TOPRIGHT', UIParent, -275, -235}
  10. -- local TEXTURE        = [[Interface\AddOns\LynExperience\assets\statusbar]]
  11. local CLASSCOLOR    = CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS[CLASS] or RAID_CLASS_COLORS[CLASS]
  12.  
  13. f = CreateFrame('Frame', nil, UIParent)
  14. f:SetPoint(POSITION[1], POSITION[2], POSITION[3], POSITION[4], POSITION[5])
  15. f:SetWidth(WIDTH)
  16. f:SetHeight(HEIGHT)
  17. f:SetScale(SCALE)
  18.  
  19.  
  20. local setBar = function(frame)
  21. --  frame:SetStatusBarTexture(TEXTURE)
  22.     frame:SetWidth(WIDTH)
  23.     frame:SetHeight(HEIGHT)
  24.     frame:SetScale(SCALE)
  25. end
  26.  
  27. local setBackdrop = function(frame)
  28.     frame.bg = CreateFrame('Frame', nil, frame)
  29.     frame.bg:SetBackdrop({
  30.         bgFile = [[Interface/Buttons/WHITE8X8]],
  31.         tiled = false,
  32.         insets = {left = 0, right = 0, top = 0, bottom = 0}
  33.     })
  34.     frame.bg:SetPoint('TOPLEFT', frame, 0, 0)
  35.     frame.bg:SetPoint('BOTTOMRIGHT', frame, 0, 0)
  36.     frame.bg:SetFrameLevel(1)
  37.     frame.bg:SetBackdropColor(0, 0, 0, 0.2)
  38.  
  39.     frame.shadow = CreateFrame('Frame', nil, frame)
  40.     frame.shadow:SetBackdrop({
  41.         bgFile = [[Interface\Tooltips\UI-Tooltip-Background]],
  42.         tiled = false,
  43.         insets = {left = 0, right = 0, top = 0, bottom = 0}
  44.     })
  45.     frame.shadow:SetPoint('TOPLEFT', frame, -3, 3)
  46.     frame.shadow:SetPoint('BOTTOMRIGHT', frame, 3, -3)
  47.     frame.shadow:SetFrameLevel(0)
  48.     frame.shadow:SetBackdropColor(0, 0, 0, 0)
  49. end
  50. local azerite = CreateFrame('StatusBar', nil, f, 'AnimatedStatusBarTemplate')
  51. setBar(azerite)
  52. azerite:SetFrameLevel(4)
  53. azerite:SetStatusBarColor(.9, .8, .6)
  54. azerite:SetAnimatedTextureColors(.9, .8, .6)
  55. azerite:SetPoint(POSITION[1], POSITION[2], POSITION[3], POSITION[4], POSITION[5] + OFFSET)
  56. setBackdrop(azerite)
  57.  
  58. local azerite_update = function(self,event)
  59.     local azeriteItemLocation = C_AzeriteItem.FindActiveAzeriteItem()
  60.     if azeriteItemLocation then
  61.         local xp, totalLevelXP = C_AzeriteItem.GetAzeriteItemXPInfo(azeriteItemLocation)
  62.         local currentLevel = C_AzeriteItem.GetPowerLevel(azeriteItemLocation)
  63.         local xpToNextLevel = totalLevelXP - xp
  64.         if not azerite:IsShown() then
  65.             azerite:Show()
  66.         end
  67.  
  68.         azerite:SetAnimatedValues(xp, 0, totalLevelXP)
  69.     else
  70.         if azerite:IsShown() then
  71.             azerite:Hide()
  72.         end
  73.     end
  74.     if event == 'AZERITE_ITEM_EXPERIENCE_CHANGED' or event == 'PLAYER_ENTERING_WORLD' then
  75.         if not azerite:IsShown() then
  76.             azerite:Show()
  77.         end
  78.     end
  79. end
  80. local showAzeriteTooltip = function(self)
  81.     local azeriteItemLocation = C_AzeriteItem.FindActiveAzeriteItem();
  82.     local azeriteItem = Item:CreateFromItemLocation(azeriteItemLocation);
  83.     local azeriteItemName = azeriteItem:GetItemName();
  84.     local xp, totalLevelXP = C_AzeriteItem.GetAzeriteItemXPInfo(azeriteItemLocation)
  85.     local currentLevel = C_AzeriteItem.GetPowerLevel(azeriteItemLocation)
  86.     local xpToNextLevel = totalLevelXP - xp
  87.     GameTooltip:SetOwner(self, 'ANCHOR_NONE')
  88.     GameTooltip:SetPoint(TIP[1], TIP[2], TIP[3], TIP[4], TIP[5])
  89.     GameTooltip:SetText(AZERITE_POWER_TOOLTIP_TITLE:format(currentLevel, xpToNextLevel), HIGHLIGHT_FONT_COLOR:GetRGB());
  90.     GameTooltip:AddLine(AZERITE_POWER_TOOLTIP_BODY:format(azeriteItemName));
  91.  
  92.     GameTooltip:Show()
  93. end
  94. azerite:SetScript('OnEnter', showAzeriteTooltip)
  95. azerite:SetScript('OnLeave', function() GameTooltip:Hide() end)
  96. azerite:SetScript("OnEvent",azerite_update)
  97. azerite:RegisterEvent('AZERITE_ITEM_EXPERIENCE_CHANGED')
  98. azerite:RegisterEvent('PLAYER_ENTERING_WORLD')

Had some time to test it ... for the tooltip you need to create the values in the correct scope.
They're local to your azerite_update function.
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
11-05-18, 04:31 PM   #15
superfula
A Deviate Faerie Dragon
Join Date: Mar 2006
Posts: 14
Wow, thank you both for the great posts! I had learned to live with the oddity so I forgot about my post here.

Rilgamon...It looks like the tooltip is fine in your code, however the azerite bar still shows on toons that do not have the azerite neck yet.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Azerite bar not showing

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off