Thread Tools Display Modes
08-30-16, 10:24 AM   #1
Uitat
A Chromatic Dragonspawn
 
Uitat's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 162
artifact xp bar

this is my error, and i dont know how to fix it
-----------------------------------------------------------------------------------------------------
40x _Deranjata\modules\xpbar\artxp.lua:35: attempt to call global 'SetValue' (a nil value)
_Deranjata\modules\xpbar\artxp.lua:35: in function <_Deranjata\modules\xpbar\artxp.lua:22>

Locals:
self = derArtifactBar {
0 = <userdata>
}
event = "UNIT_INVENTORY_CHANGED"
showArtifact = true
itemID = 128866
altItemID = 128867
name = "Truthguard"
icon = 1272527
totalXP = 100
pointsSpent = 0
numPoints = 1
artifactXP = 0
xpForNextPoint = 300
(*temporary) = nil
(*temporary) = derArtifactBar {
0 = <userdata>
}
(*temporary) = 0
(*temporary) = "attempt to call global 'SetValue' (a nil value)"
------------------------------------------------------------------------
here is my code
Lua Code:
  1. derArtifactBar:RegisterEvent("PLAYER_ENTERING_WORLD")
  2. derArtifactBar:RegisterEvent("ARTIFACT_XP_UPDATE")
  3. derArtifactBar:RegisterEvent("UNIT_INVENTORY_CHANGED")
  4. derArtifactBar:SetScript("OnEvent", function(self, event, ...)
  5.         local showArtifact = HasArtifactEquipped()
  6.         if not showArtifact then
  7.             if self:IsShown() then
  8.                 self:Hide()
  9.             end
  10.             return
  11.         end
  12.         if not self:IsShown() then
  13.             self:Show()
  14.         end
  15.         local itemID, altItemID, name, icon, totalXP, pointsSpent = C_ArtifactUI.GetEquippedArtifactInfo()
  16.         local numPoints, artifactXP, xpForNextPoint = MainMenuBar_GetNumArtifactTraitsPurchasableFromXP(pointsSpent, totalXP)
  17.         SetValue(self, artifactXP/xpForNextPoint)
  18.     end)
my problem:

SetValue(self, artifactXP/xpForNextPoint)
is throwing an error for
derArtifactBar:SetScript("OnEvent", function(self, event, ...)
__________________

Last edited by Uitat : 08-30-16 at 10:37 AM.
  Reply With Quote
08-30-16, 10:48 AM   #2
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
SetValue does not exist as a global, it is only inherited in frames. Change SetValue to self:SetValue and you should be fine.
  Reply With Quote
08-31-16, 06:52 AM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
And after doing that, the "self" you're passing it as the first argument needs to be removed, too:

SetValue(self, ...) => self:SetValue(...)
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
08-31-16, 09:19 AM   #4
Uitat
A Chromatic Dragonspawn
 
Uitat's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 162
i dont know

i dont know i may have to rebuild this, even with your guy's help, its not working
__________________
  Reply With Quote
08-31-16, 09:38 AM   #5
Uitat
A Chromatic Dragonspawn
 
Uitat's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 162
ok i have no errors but also have no status

im using Dominos to show as reference...
what i am expecting to happen here ... in the box with the stripes is what you se just above it(dominos artifact bar)
what im getting is nothing,
there is no errors, but also no info...
---- See Attached Thumbnail below ----
code
Lua Code:
  1. local derArtifactBar = CreateFrame("Statusbar", "derArtifactBar",artifactFrame)
  2. derArtifactBar:SetPoint("CENTER", 0, 0)
  3. derArtifactBar:SetHeight(17)
  4. derArtifactBar:SetWidth(artifactFrame:GetWidth() * .968)
  5.  
  6.  
  7. derArtifactBar:SetBackdrop({
  8.     bgFile =  "Interface\\AddOns\\_Deranjata\\media\\cast\\Lines",
  9. --  edgeFile = "Interface\\BUTTONS\\WHITE8X8", edgeSize = 1,
  10.     insets = { left = 1, right = 1, top = 1, bottom = 1 }
  11. })
  12. derArtifactBar:SetBackdropColor(0.1, 0.1, 0.1)
  13. derArtifactBar:SetBackdropBorderColor(0.6, 0.6, 0.6)
  14.  
  15.  
  16.  
  17.  
  18. derArtifactBar:RegisterEvent("PLAYER_ENTERING_WORLD")
  19. derArtifactBar:RegisterEvent("ARTIFACT_XP_UPDATE")
  20. derArtifactBar:RegisterEvent("UNIT_INVENTORY_CHANGED")
  21. derArtifactBar:SetScript("OnEvent", function(self, event, ...)
  22.         local showArtifact = HasArtifactEquipped()
  23.         if not showArtifact then
  24.             if self:IsShown() then
  25.                 self:Hide()
  26.             end
  27.             return
  28.         end
  29.         if not self:IsShown() then
  30.             self:Show()
  31.         end
  32.        
  33.         local itemID, altItemID, name, icon, totalXP, pointsSpent = C_ArtifactUI.GetEquippedArtifactInfo()
  34.         local numPoints, artifactXP, xpForNextPoint = MainMenuBar_GetNumArtifactTraitsPurchasableFromXP(pointsSpent, totalXP)
  35.         self:SetValue(artifactXP/xpForNextPoint)
  36.  
  37.     end)
Attached Thumbnails
Click image for larger version

Name:	artifactBar.png
Views:	267
Size:	220.7 KB
ID:	8801  
__________________
  Reply With Quote
08-31-16, 11:12 AM   #6
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
it doesn't have a derArtifactBar:SetStatusBarTexture(...) to draw.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
08-31-16, 12:35 PM   #7
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
What are the min/max values on your statusbar?
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
08-31-16, 12:44 PM   #8
Uitat
A Chromatic Dragonspawn
 
Uitat's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 162
Originally Posted by Seerah View Post
What are the min/max values on your statusbar?
I believe the max on the bar is 375 if i am remembering right. And the min is 0 of course.. im away from pc and driving at the m9ment but ill log into wow and check wows max on the artifact bar
__________________
  Reply With Quote
08-31-16, 06:05 PM   #9
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Uitat View Post
I believe the max on the bar is 375 if i am remembering right. And the min is 0 of course.. im away from pc and driving at the m9ment but ill log into wow and check wows max on the artifact bar
There's nothing in the code you posted that applies min/max values to your statusbar.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
08-31-16, 06:13 PM   #10
Uitat
A Chromatic Dragonspawn
 
Uitat's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 162
Originally Posted by Phanx View Post
There's nothing in the code you posted that applies min/max values to your statusbar.

i thought thats what i was doing with this

self:SetValue(artifactXP/xpForNextPoint)
__________________
  Reply With Quote
08-31-16, 07:36 PM   #11
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
No, that sets the CURRENT value of your statusbar, which should be a number somewhere between the min and max values.

http://wowprogramming.com/docs/widgets/StatusBar
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
08-31-16, 08:34 PM   #12
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
Originally Posted by Uitat View Post
i thought thats what i was doing with this

self:SetValue(artifactXP/xpForNextPoint)
artifactXP/xpForNextPoint is a mathematical expression that evaluates to a number that is used as the current value, it doesn't tell the function in any way what the range the StatusBar is supposed to cover. To define that, you use StatusBar:SetMinMaxValues().
Code:
self:SetMinMaxValues(0,xpForNextPoint)
self:SetValue(artifactXP)
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
08-31-16, 09:58 PM   #13
Uitat
A Chromatic Dragonspawn
 
Uitat's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 162
thank you all for the info, it physically works now just the text formatting

this is my formatting for the standard xp/rep bars, how would i implement this here, as i am unable to fully comprehend the API for the artifact bars i am still having issues

Lua Code:
  1. local xp, max, rest = UnitXP("player"), UnitXPMax("player"), GetXPExhaustion()
  2. text:SetFormattedText("Level %d XP: %d / %d", level, xp, max)

would i change out to

Lua Code:
  1. local  max, current  =  xpForNextPoint, artifactXP
  2. text:SetFormattedText("XP: %d / %d ", current , max)
__________________
  Reply With Quote
09-01-16, 12:00 AM   #14
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
You should just use those values directly instead of wasting resources copying them into more variables.
Code:
text:SetFormattedText("XP: %d / %d ",artifactXP,xpForNextPoint)
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
09-01-16, 05:32 AM   #15
Uitat
A Chromatic Dragonspawn
 
Uitat's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 162
ok in end

ok so at the end of this all it works fine now and i am mostly happy. now i just want to have a + then number for levels accumulated on the bar before spending, i can figure that out at some time , for now i am just glad to have this

Lua Code:
  1. local AXP_COLOR = { r = 0.6, g = 0.2, b = 0.1 }
  2.  
  3. local derArtifactBar = CreateFrame("Statusbar", "derArtifactBar",artifactFrame)
  4. derArtifactBar:SetPoint("CENTER", 0, 0)
  5. derArtifactBar:SetHeight(18)
  6. derArtifactBar:SetWidth(artifactFrame:GetWidth() * .968)
  7. derArtifactBar:SetStatusBarTexture("Interface\\AddOns\\_Deranjata\\media\\cast\\Waterline")
  8. derArtifactBar:SetStatusBarColor(AXP_COLOR.r, AXP_COLOR.g, AXP_COLOR.b, 0.5)
  9. derArtifactBar:SetBackdrop({
  10.     bgFile =  "Interface\\AddOns\\_Deranjata\\media\\cast\\Lines",
  11.     insets = { left = 1, right = 1, top = 1, bottom = 1 }
  12. })
  13. derArtifactBar:SetBackdropColor(0.1, 0.1, 0.1)
  14. derArtifactBar:SetBackdropBorderColor(0.6, 0.6, 0.6)
  15. derArtifactBar:RegisterEvent("PLAYER_ENTERING_WORLD")
  16. derArtifactBar:RegisterEvent("ARTIFACT_XP_UPDATE")
  17. derArtifactBar:RegisterEvent("UNIT_INVENTORY_CHANGED")
  18. derArtifactBar:SetScript("OnEvent", function(self, event, ...)
  19.  
  20. local showArtifact = HasArtifactEquipped()
  21.       if not showArtifact then
  22.           if self:IsShown() then
  23.               self:Hide()
  24.           end
  25.           return
  26.       end
  27.       if not self:IsShown() then
  28.           self:Show()
  29.       end
  30. local itemID, altItemID, name, icon, totalXP, pointsSpent = C_ArtifactUI.GetEquippedArtifactInfo()
  31. local numPoints, artifactXP, xpForNextPoint = MainMenuBar_GetNumArtifactTraitsPurchasableFromXP(pointsSpent, totalXP)
  32.         self:SetMinMaxValues(0,xpForNextPoint)
  33.         self:SetValue(artifactXP)
  34.        
  35. local bar = CreateFrame("StatusBar", nil, derArtifactBar)
  36.         bar:SetAllPoints(true)
  37. local text = bar:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  38.         text:SetPoint("CENTER")    
  39.         text:SetFormattedText("Artifact XP: %d / %d ",artifactXP,xpForNextPoint)
  40. end)
__________________
  Reply With Quote
09-01-16, 07:50 AM   #16
Uitat
A Chromatic Dragonspawn
 
Uitat's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 162
solved

got the points added by doing....

text:SetFormattedText("Artifact XP: %d / %d + %d",artifactXP,xpForNextPoint, numPoints)

result on bar.... Artifact XP: 185/375 +3

id say im happy with this!!!
__________________
  Reply With Quote
09-01-16, 01:01 PM   #17
Uitat
A Chromatic Dragonspawn
 
Uitat's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 162
One last problem. When aryifact xp is added to my bar i get an aditional text layer over the first layer. Can someone test the code and see if you get the same result?
__________________
  Reply With Quote
09-01-16, 01:04 PM   #18
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
You are creating derArtifactBar multiple times. Once at load and again whenever any of those 3 events fire. Same goes with the fontstring - a new fontstring is being created every time an event fires.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
09-02-16, 06:32 AM   #19
Uitat
A Chromatic Dragonspawn
 
Uitat's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 162
Originally Posted by Seerah View Post
You are creating derArtifactBar multiple times. Once at load and again whenever any of those 3 events fire. Same goes with the fontstring - a new fontstring is being created every time an event fires.
seerah i hate to ask this, but can you help me here turn this into a function that does waht my xp bar does(NOT OVERLAP TEXT). maybe walk me through turning it into a proper function, that works having arguments such as if not in petbattle then show it, if artifact equipped then show it, then finally run said functions on events that are prescribed?

sorry sending from my S7 Android
__________________
  Reply With Quote
09-02-16, 11:12 AM   #20
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
You need to move these lines out of the event handler. Probably to the main scope.
Code:
local bar = CreateFrame("StatusBar", nil, derArtifactBar)
bar:SetAllPoints(true)
local text = bar:CreateFontString(nil, "OVERLAY", "GameFontNormal")
text:SetPoint("CENTER")
Do you really want to create another bar on top the existing one, though?
__________________
Grab your sword and fight the Horde!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » artifact xp bar

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