WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   artifact xp bar (https://www.wowinterface.com/forums/showthread.php?t=54343)

Uitat 08-30-16 10:24 AM

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, ...)

Kanegasi 08-30-16 10:48 AM

SetValue does not exist as a global, it is only inherited in frames. Change SetValue to self:SetValue and you should be fine.

Phanx 08-31-16 06:52 AM

And after doing that, the "self" you're passing it as the first argument needs to be removed, too:

SetValue(self, ...) => self:SetValue(...)

Uitat 08-31-16 09:19 AM

i dont know
 
i dont know i may have to rebuild this, even with your guy's help, its not working

Uitat 08-31-16 09:38 AM

ok i have no errors but also have no status
 
1 Attachment(s)
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)

Fizzlemizz 08-31-16 11:12 AM

it doesn't have a derArtifactBar:SetStatusBarTexture(...) to draw.

Seerah 08-31-16 12:35 PM

What are the min/max values on your statusbar?

Uitat 08-31-16 12:44 PM

Quote:

Originally Posted by Seerah (Post 318573)
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

Phanx 08-31-16 06:05 PM

Quote:

Originally Posted by Uitat (Post 318576)
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.

Uitat 08-31-16 06:13 PM

Quote:

Originally Posted by Phanx (Post 318583)
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)

Seerah 08-31-16 07:36 PM

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

SDPhantom 08-31-16 08:34 PM

Quote:

Originally Posted by Uitat (Post 318585)
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)


Uitat 08-31-16 09:58 PM

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)

SDPhantom 09-01-16 12:00 AM

You should just use those values directly instead of wasting resources copying them into more variables.
Code:

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

Uitat 09-01-16 05:32 AM

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)

Uitat 09-01-16 07:50 AM

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!!!

Uitat 09-01-16 01:01 PM

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?

Seerah 09-01-16 01:04 PM

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.

Uitat 09-02-16 06:32 AM

Quote:

Originally Posted by Seerah (Post 318618)
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

Lombra 09-02-16 11:12 AM

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?


All times are GMT -6. The time now is 03:53 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI