Thread Tools Display Modes
08-26-09, 03:11 PM   #1
saxitoxin
A Theradrim Guardian
 
saxitoxin's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 60
help with code

Why does not this code work?

local addon = CreateFrame("Frame", nil, UIParent)
-- frame
local frame_anchor = "BOTTOMLEFT"
local frame_x = 750
local frame_y = 400
-- font
local font = "Fonts\\SKURRI.ttf"
local size = 14
local outline = false
local shadow = false
local text_anchor = "BOTTOMLEFT"
-- used locals
local text, pvalue
-- new
function addon:new()
-- frame position
self:SetPoint(frame_anchor, UIParent, frame_anchor, frame_x, frame_y)
self:SetWidth(40)
self:SetHeight(11)
-- create fontstring
text = self:CreateFontString(nil, "OVERLAY")
- text style
if outline == true then
text:SetFont(font, size, "THINOUTLINE")
else
text:SetFont(font, size, nil)
end
text:SetPoint(text_anchor, self)

self:RegisterEvent("UNIT_HEALTH")
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("PLAYER_LOGIN")

-- update
self:SetScript("OnUpdate", self.update)
self:SetScript("OnEvent", self.event)
end
function addon:event()
if (event == "UNIT_HEALTH") then
pvalue:SetText(floor(((UnitHealth("player") / UnitHealthMax("player"))*100)+5).."%")
elseif event == "PLAYER_ENTERING_WORLD" then
pvalue:SetText(floor(((UnitHealth("player") / UnitHealthMax("player"))*100)+5).."%")
elseif event == "PLAYER_LOGIN" then
pvalue:SetText(floor(((UnitHealth("player") / UnitHealthMax("player"))*100)+5).."%")
end
end
-- update function
function addon:update()
-- set it
text:SetText(pvalue)
end
-- fire
addon:new()

Last edited by saxitoxin : 08-26-09 at 03:20 PM. Reason: been trying to do that, aint happen srry
  Reply With Quote
08-26-09, 03:15 PM   #2
Nuckin
is laughing at you
 
Nuckin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 58
Some indenting and code formating wouldn't hurt, in its current state it is horrid to read.
__________________
SELECT * FROM users WHERE clue > 0;
0 rows returned.
  Reply With Quote
08-26-09, 04:56 PM   #3
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
You're trying to use SetText on a variable, yet you can only do that on a fontstring.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » help with code


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