Thread Tools Display Modes
Prev Previous Post   Next Post Next
07-07-14, 02:22 PM   #1
Kygo
A Theradrim Guardian
 
Kygo's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 64
oUF_Kygo, a few tips wanted

Heya!
Just a bit of a FYI, this might be long post, I'm really new when it comes to LUA.
After a little absence from WoW I'm back , and I got the idea to create my own layout for my AddOn comp which is currently using oUF_Phanx. (http://www.wowinterface.com/download...-oUFPhanx.html)

Been trying to put something really simple togheter first, but so far no luck at all. Or the lack of skills might be the correct word.
All I've managed to get working is this:
Lua Code:
  1. local _, ns = ...
  2. local _, playerClass = UnitClass("player")
  3. local colors = oUF.colors
  4. local config
  5.  
  6. ns.frames, ns.headers, ns.objects, ns.fontstrings, ns.statusbars = {}, {}, {}, {}, {}
  7.  
  8. -- Frames
  9. local function Spawn(frame, unit, isSingle)
  10.     frame:SetPoint("CENTER", UIParent)
  11.     frame:SetSize(100, 25)
  12.  
  13.     local bg = frame:CreateTexture(nil, "BACKGROUND")
  14.     bg:SetAllPoints(true)
  15.     bg:SetTexture(0, 0, 0, 0.5)
  16.     frame.bg = bg
  17.    
  18.     local name = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  19.     name:SetPoint("BOTTOM", frame, "TOP")
  20.     self:Tag(name, "[name]")
  21.     frame.Name = name
  22. end

It does not do a whole lot more than a small black box in the middle of the screen (Thats what it's supposed to do).
And it throws a LUA error which has caused me to scratch my head a whole lot. Line 27 is "self:Tag(name, "[name]").
Lua Code:
  1. Message: Interface\AddOns\oUF_Kygo\Frames.lua:27: attempt to index global 'self' (a nil value)
  2. Time: 07/07/14 22:15:18
  3. Count: 1
  4. Stack: Interface\AddOns\oUF_Kygo\Frames.lua:27: in function `styleFunc'
  5. Interface\AddOns\oUF\ouf.lua:262: in function <Interface\AddOns\oUF\ouf.lua:192>
  6. (tail call): ?
  7. Interface\AddOns\oUF\ouf.lua:552: in function `Spawn'
  8. Interface\AddOns\oUF_Kygo\Frames.lua:63: in main chunk
  9.  
  10. Locals: frame = oUF_KygoPlayer {
  11.  0 = <userdata>
  12.  bg = <unnamed> {
  13.  }
  14.  style = "Kygo"
  15.  UNIT_EXITED_VEHICLE = <function> defined @Interface\AddOns\oUF\ouf.lua:38
  16.  UNIT_ENTERED_VEHICLE = <function> defined @Interface\AddOns\oUF\ouf.lua:38
  17.  PLAYER_ENTERING_WORLD = <function> defined @Interface\AddOns\oUF\ouf.lua:149
  18.  __elements = <table> {
  19.  }
  20.  unit = "player"
  21. }
  22. unit = "player"
  23. isSingle = true
  24. bg = <unnamed> {
  25.  0 = <userdata>
  26. }
  27. name = <unnamed> {
  28.  0 = <userdata>
  29. }
  30. (*temporary) = nil
  31. (*temporary) = nil
  32. (*temporary) = "BOTTOM"
  33. (*temporary) = oUF_KygoPlayer {
  34.  0 = <userdata>
  35.  bg = <unnamed> {
  36.  }
  37.  style = "Kygo"
  38.  UNIT_EXITED_VEHICLE = <function> defined @Interface\AddOns\oUF\ouf.lua:38
  39.  UNIT_ENTERED_VEHICLE = <function> defined @Interface\AddOns\oUF\ouf.lua:38
  40.  PLAYER_ENTERING_WORLD = <function> defined @Interface\AddOns\oUF\ouf.lua:149
  41.  __elements = <table> {
  42.  }
  43.  unit = "player"
  44. }
  45. (*temporary) = "TOP"
  46. (*temporary) = "attempt to index global 'self' (a nil value)"



Been trying to use diffrent variants of Healthbar and powerbar code snippets (Everything from Zork's oUF_Simple to oUF_Phanx) but when I start WoW back up with the new code in place , it's only showing the standard Blizzard UnitFrames.
The code I've been trying to make it work is this:
Lua Code:
  1. -- Health bar
  2.     local Health = CreateFrame("FRAME", nil, self)
  3.     Health:SetHeight(14)
  4. --  Health:SetStatusBarTexture(_TEXTURE)
  5.  
  6.     Health:SetPoint("TOP", 0, -8)
  7.     Health:SetPoint("LEFT", 8, 0)
  8.     Health:SetPoint('RIGHT', -90, 0)
  9.  
  10.     Health.frequentUpdates = true
  11.     Health.colorDisconnected = true
  12.     Health.colorTapping = true
  13.     Health.colorSmooth = true
  14.  
  15.     Health.PostUpdate = PostUpdateHealth
  16.  
  17.     self.Health = health
  18.  
  19.     local HealthPoints = Health:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  20.     HealthPoints:SetPoint("LEFT", Health, "RIGHT", 2, -1)
  21.     HealthPoints:SetPoint("RIGHT", self, -6, -1)
  22.     HealthPoints:SetJustifyH"CENTER"
  23.     HealthPoints:SetFont(GameFontNormal:GetFont(), 10)
  24.     HealthPoints:SetTextColor(1, 1, 1)
  25.  
  26.     self:Tag(HealthPoints, '[dead][offline][classic:health]')
  27.  
  28.     Health.value = HealthPoints

If this code is out of date or just plain wrong, no need to sugar coat it!

Last edited by Kygo : 07-08-14 at 12:48 PM. Reason: Noticed error with link
  Reply With Quote
 

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » oUF_Kygo, a few tips wanted


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