Thread Tools Display Modes
09-08-10, 08:47 AM   #1
ezarra
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 123
Putting Text on an overlay

in my XML I have

Code:
<StatusBar name="EZXPBarXP" inherits="TextStatusBar" frameStrata="LOW">
    <Size>
        <AbsDimension x="118" y="5"/>
    </Size>
    <Anchors>
        <Anchor point="TOPLEFT" relativeTo="EZXPBar" relativePoint="TOPLEFT">
            <Offset>
                <AbsDimension x="5" y="-5"/>
            </Offset>
        </Anchor>
    </Anchors>
    <Scripts>
        <OnEvent>
            EZXPBar_OnEvent(event);
        </OnEvent>
    </Scripts>
    <BarTexture file="Interface\TargetingFrame\UI-StatusBar"/>
    <BarColor r="0.5" g="0" b="0.5"/>
    <Layers>
        <Layer level="OVERLAY">
            <FontString name="EZXPBar_TEXT" inherits="GameFontNormalSmall">
                <Shadow/>
                <Color r="1" g="1" b="0"/>
            </FontString>
        </Layer>					
    </Layers>
</StatusBar>
Now, I am trying to set the text and color in my lua:

Code:
if (GetXPExhaustion() ~= nil) then
    EZXPBarXP:SetStatusBarColor(0.8,0.6,0);
    EZXPBar_TEXT:SetText(COLOR1 ..dispRP );
else
   EZXPBar_TEXT:SetText(COLOR1 .. dispXP);
   EZXPBarXP:SetStatusBarColor(0,0,1);
end
Trouble is, neither the color not the text setting appear to do anything at all
__________________
Dude, if you wanted to win, why'd you let me play?
 
09-08-10, 10:40 AM   #2
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 793
It's just an suggestion I quickly wrote, did not check if it's valid or if I wrote something wrong but the general idea is that you can make the whole thing in much shorter code:

Code:
local f = CreateFrame("Frame", "EZXPBarXP", "you-should-enter-parent-name-here-as-in-the-name-of-th-expbar-for-example-or-set-this-quote-to-nil", "TextStatusBar")
f:SetPoint("TOPLEFT", f, "TOPLEFT", 5, -5)
f:SetScript("OnEvent", EZXPBar_OnEvent)
f.bar = CreateFrame("BarTexture", f)
f.bar:SetFile([[Interface\TargetingFrame\UI-StatusBar]])
f.bar:SetStatusBarColor(0.5, g, 0.5)
f.txt = CreateFrame("FontString", "EZXPBar_TEXT", nil, "GameFontNormalSmall")
f.txt:SetColor(1, 1, 0)

local function set(text)
  if not GetXPExhaustion() then
    f.bar:SetStatusBarColor(0.8, 0.6, 0)
    f.txt:SetText(COLOR1..dispRP)
  else
    f.bar:SetStatusBarColor(0, 0, 1)
    f.txt:SetText(COLOR1..dispXP)
  end
end
Also note that names are not required for reference, local variables work just fine as well.

About the issue, I am not pro enough to see a problem in the code atm.
 
09-09-10, 09:32 AM   #3
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
What I found to be best of use if I wanted to do this is to use helper frames.

I create myself frames and give them a certain framelevel.

Code:
local f1:CreateFrame("FRAME", nil, UIParent)
local f2:CreateFrame("FRAME", nil, UIParent)

local f1:SetFrameLevel(1)
local f2:SetFrameLevel(2)
http://www.wowwiki.com/API_Frame_SetFrameLevel

I then apply any texture/font to that frame on the specific level.

So it's possible to write strings on top of an animated PlayerModel and such.

Higher numbers will always be on top of frames with lower numbers, thats how it works.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
 
09-09-10, 09:51 AM   #4
yj589794
A Rage Talon Dragon Guard
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 314
From http://www.wowwiki.com/FrameLevel ...

You can check a frame's level with Frame:GetFrameLevel() and you can set it with Frame:SetFrameLevel(). However, setting a frame's level is ill-advised. It is given its level automatically and it's best to leave it that way. If you need to change a frame's level in your own code, best thing to do is just nest your code differently.
Correctly structuring your frame creation is preferable to manually forcing them to a specific level.
 
09-09-10, 09:57 AM   #5
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Yeah. Dream on. Things never turn out the way you think it "should be".
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
 
09-09-10, 05:17 PM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
They do if you bother to learn how they work before using them, especially when you're talking about programming, which follows a set of fixed rules...
 
 

WoWInterface » AddOns, Compilations, Macros » Cataclysm Beta » Putting Text on an overlay

Thread Tools
Display Modes

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