View Single Post
07-09-14, 09:46 AM   #3
Kygo
A Theradrim Guardian
 
Kygo's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 64
Thank you so much Phanx for the explination of my errors and corrected me!
I will learn to use the correct capitalization in my code!

The code snippets I found inside oUF_Phanx , I thought those were requiered for the code to run, for instance that the "local _, ns = ..." told oUF the code to oUF so it knew what to run?

Great! Got the name working, did play around with the settings for size, alpha and color!

Now I've been trying to make the healthbar appear and work, did as you said, swapped out ' for " on a few places, and did swap out "self" for "Frame" due to because I have not defined "self" anywhere.
How the health code looks right now:
(Did add "local function Spawn(Frame, unit, isSingle) because without it threw a error, can post it aswell if needed/wanted)
Lua Code:
  1. -- Health bar
  2. local function Spawn(Frame, unit, isSingle)
  3.     Frame:SetPoint("CENTER", UIParent)
  4.     Frame:SetSize(100, 25)
  5.    
  6.     local Health = CreateFrame("Frame", nil, self)
  7.     Health:SetHeight(25)
  8. --  Health:SetStatusBarTexture(_TEXTURE)
  9.  
  10.     Health:SetPoint("TOP", 0, -8)
  11.     Health:SetPoint("LEFT", 8, 0)
  12.     Health:SetPoint("RIGHT", -90, 0)
  13.    
  14.  
  15.     Health.frequentUpdates = true
  16.     Health.colorDisconnected = true
  17.     Health.colorTapping = true
  18.     Health.colorSmooth = true
  19.  
  20.     Health.PostUpdate = PostUpdateHealth
  21.  
  22.     Frame.Health = Health
  23.    
  24.     local HealthPoints = Health:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  25.     HealthPoints:SetPoint("LEFT", Health, "RIGHT", 2, -1)
  26.     HealthPoints:SetPoint("RIGHT", self, -6, -1)
  27.     --HealthPoints:SetJustify("CENTER")
  28.     HealthPoints:SetFont(GameFontNormal:GetFont(), 10)
  29.     HealthPoints:SetTextColor(1, 1, 1)
  30.  
  31.     Frame:Tag(HealthPoints,"[dead][offline]")
  32.    
  33.  
  34.     Health.value = HealthPoints
  35. end

But now is that code throwing a diffrent error. The LUA error that code throws:
Got a LUA error saying that [classic:Health] is invalid so i did just remove that part for now.
And my black box with my name on top of it did disappear :S But I did not get a standard Blizzard Unitframe for the player!

Code:
Message: Interface\AddOns\oUF\elements\health.lua:99: attempt to call method 'SetMinMaxValues' (a nil value)
Time: 07/09/14 17:33:36
Count: 1
Stack: Interface\AddOns\oUF\elements\health.lua:99: in function <Interface\AddOns\oUF\elements\health.lua:91>
(tail call): ?
Interface\AddOns\oUF\ouf.lua:158: in function <Interface\AddOns\oUF\ouf.lua:149>
(tail call): ?

Locals: self = oUF_KygoPlayer {
 0 = <userdata>
 __tags = <table> {
 }
 PLAYER_ENTERING_WORLD = <function> defined @Interface\AddOns\oUF\ouf.lua:149
 UNIT_FACTION = <function> defined @Interface\AddOns\oUF\elements\health.lua:147
 unit = "player"
 UNIT_CONNECTION = <function> defined @Interface\AddOns\oUF\elements\health.lua:147
 UNIT_EXITED_VEHICLE = <function> defined @Interface\AddOns\oUF\ouf.lua:38
 style = "Kygo"
 Health = <unnamed> {
 }
 UNIT_HEALTH_FREQUENT = <function> defined @Interface\AddOns\oUF\elements\health.lua:147
 UNIT_MAXHEALTH = <function> defined @Interface\AddOns\oUF\elements\health.lua:147
 __elements = <table> {
 }
 UNIT_ENTERED_VEHICLE = <function> defined @Interface\AddOns\oUF\ouf.lua:38
}
event = "PLAYER_ENTERING_WORLD"
unit = "player"
health = <unnamed> {
 __owner = oUF_KygoPlayer {
 }
 colorSmooth = true
 colorTapping = true
 ForceUpdate = <function> defined @Interface\AddOns\oUF\elements\health.lua:151
 value = <unnamed> {
 }
 0 = <userdata>
 frequentUpdates = true
 colorDisconnected = true
}
min = 154
max = 154
disconnected = false
(*temporary) = nil
(*temporary) = <unnamed> {
 __owner = oUF_KygoPlayer {
 }
 colorSmooth = true
 colorTapping = true
 ForceUpdate = <function> defined @Interface\AddOns\oUF\elements\health.lua:151
 value = <unnamed> {
 }
 0 = <userdata>
 frequentUpdates = true
 colorDisconnected = true
}
(*temporary) = 0
(*temporary) = 154
(*temporary) = "attempt to call method 'SetMinMaxValues' (a nil value)"
Did look through the health.lua inside \oUF\elements to see if I could find arguments or what to call them that looks like those I already have inside the code, but could not find any. (Could have missed them, will look through the code again)


http://pastebin.com/u/Kygo , the full code and errors.

Last edited by Kygo : 07-09-14 at 09:56 AM. Reason: Added pastebin link
  Reply With Quote