09-23-18, 08:15 PM | #1 |
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" 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. |
|
09-23-18, 08:39 PM | #2 |
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. |
|
09-23-18, 08:44 PM | #3 |
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.
|
|
09-23-18, 10:00 PM | #4 |
Code:
local azeriteItemLocation = C_AzeriteItem.FindActiveAzeriteItem()
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. |
|
09-23-18, 10:31 PM | #5 |
09-24-18, 12:09 AM | #6 | |
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. |
||
09-26-18, 11:23 PM | #7 | |
Last edited by superfula : 09-26-18 at 11:36 PM. |
||
09-27-18, 12:09 AM | #8 |
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! |
|
09-27-18, 12:28 AM | #9 | |
Code:
if event == 'AZERITE_ITEM_EXPERIENCE_CHANGED' or event == 'PLAYER_ENTERING_WORLD' then if not azerite:IsShown() then azerite:Show() end end |
||
09-27-18, 01:31 AM | #10 |
Lua Code:
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! |
|
09-27-18, 10:40 AM | #11 | |
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. |
||
09-27-18, 11:15 AM | #12 |
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 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. |
|
09-27-18, 04:47 PM | #13 |
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() ) Code:
local xp, totalXP = C_AzeriteItem.GetAzeriteItemXPInfo(azeriteItemLocation); local currentLevel = C_AzeriteItem.GetPowerLevel(azeriteItemLocation); local xpToNextLevel = totalXP - xp; local pct = xp / totalXP 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 );
__________________
Characters: Gwynedda - 70 - Demon Warlock Galaviel - 65 - Resto Druid Gamaliel - 61 - Disc Priest Gwynytha - 60 - Survival Hunter Lienae - 60 - Resto Shaman Plus several others below level 60 Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818 |
|
09-29-18, 05:31 AM | #14 |
Lua Code:
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! |
|
11-05-18, 04:31 PM | #15 |
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. |
|
WoWInterface » Developer Discussions » General Authoring Discussion » Azerite bar not showing |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|