Thread Tools Display Modes
12-04-09, 07:03 PM   #1
doomie22
A Murloc Raider
Join Date: Oct 2008
Posts: 9
Getting data into a frame?

Hi,

I am very new to this so I am really not sure what I am doing yet but here goes.

I am trying to get gold to display in a frame (hoping not to use xml)

Code:
local TotalValue = GetMoney()/10000;
local TGold = tonumber(string.sub(TotalValue,1,-6)) if TGold == nil or TGold == 0 then TGold = "" else TGold = (TGold.."g, ") end
local TSilver = tonumber(string.sub(TotalValue,-4,-3)) if TSilver == nil or TSilver == 0 then TSilver = "" else TSilver = (TSilver.."s, ") end
local TCopper = tonumber(string.sub(TotalValue,-2,-1)) if TCopper == nil or TCopper == 0 then TCopper = "" else TCopper = (TCopper.."c") end
I would like to know how to get this to display in a window (one that will stay there), I just want it to show 1st and nothing more atm.

I can call it with this okay, so I know its working okay.

Code:
DEFAULT_CHAT_FRAME:AddMessage("You have a total of "..TGold..TSilver..TCopper..".");
Can anyone help please.

Thanks,

Doomie

Last edited by doomie22 : 12-04-09 at 07:25 PM.
  Reply With Quote
12-04-09, 07:33 PM   #2
doomie22
A Murloc Raider
Join Date: Oct 2008
Posts: 9
I have just found this on wowwiki, so I have the 2 things I need so far, just need to find the way to put them together.

Code:
local f = CreateFrame("Frame",nil,Minimap)
f:SetFrameStrata("BACKGROUND")
f:SetWidth(128) -- Set these to whatever height/width is needed 
f:SetHeight(64) -- for your Texture

local t = f:CreateTexture(nil,"BACKGROUND")
t:SetTexture("Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Factions.blp")
t:SetAllPoints(f)
f.texture = t

f:SetPoint("CENTER",0,-135)
f:Show()
  Reply With Quote
12-04-09, 07:42 PM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
You need to create a fontstring for your text.
__________________
"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
12-04-09, 07:53 PM   #4
doomie22
A Murloc Raider
Join Date: Oct 2008
Posts: 9
Originally Posted by Seerah View Post
You need to create a fontstring for your text.
Not sure what you mean atm (only started messing with addons today, so really new to this)

Looking at wowwiki I can see the following:

FontString:SetText(string text) and text = FontString:GetText();

Are these what I should be looking at?

Thanks,

Doomie
  Reply With Quote
12-04-09, 08:15 PM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
http://wowprogramming.com/docs/widge...eateFontString
http://wowprogramming.com/docs/widgets/FontString
__________________
"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
12-04-09, 09:07 PM   #6
doomie22
A Murloc Raider
Join Date: Oct 2008
Posts: 9
I have looked at the links and I am now even more confused, does anyone have an example I can look at to try to get my head around please?
  Reply With Quote
12-04-09, 09:22 PM   #7
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Code:
local f = CreateFrame("Frame", nil, UIParent)
f:SetWidth(128) -- Set these to whatever height/width is needed 
f:SetHeight(64) -- for your Texture
f:SetPoint("CENTER")

local text = f:CreateFontstring(nil, nil, GameFontNormal)  -- you can either inherit from another font object in the game, or manually use text:SetFont("path\\to\\font.ttf", fontsize, "fontflag")
text:SetPoint("CENTER", f)
text:SetText("You have a total of "..TGold..TSilver..TCopper..".")
__________________
"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
12-05-09, 05:38 AM   #8
doomie22
A Murloc Raider
Join Date: Oct 2008
Posts: 9
Originally Posted by Seerah View Post
Code:
local f = CreateFrame("Frame", nil, UIParent)
f:SetWidth(128) -- Set these to whatever height/width is needed 
f:SetHeight(64) -- for your Texture
f:SetPoint("CENTER")

local text = f:CreateFontstring(nil, nil, GameFontNormal)  -- you can either inherit from another font object in the game, or manually use text:SetFont("path\\to\\font.ttf", fontsize, "fontflag")
text:SetPoint("CENTER", f)
text:SetText("You have a total of "..TGold..TSilver..TCopper..".")
I have given this a try but it errors on

local text = f:CreateFontstring(nil, nil, GameFontNormal)

with the following

(*temporary) = "attempt to call method 'CreateFontstring' (a nil value)"

Doomie
  Reply With Quote
12-05-09, 05:50 AM   #9
Ailae
A Rage Talon Dragon Guard
 
Ailae's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 318
Think it should be 'CreateFontString' - notice the capital S.
__________________
Oh, the simulated horror!
  Reply With Quote
12-05-09, 06:01 AM   #10
doomie22
A Murloc Raider
Join Date: Oct 2008
Posts: 9
Ty for that, never saw that part.

I now have an issue with the SetText line, get the following

(*temporary) = <unnamed> {
0 = <userdata>
}
(*temporary) = "You have a total of 139g, 99s, 93c."


Sorry to be so dumb with it, but once I have it working infront of me I will be able to understand it and it will sink in
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Getting data into a frame?


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