Thread Tools Display Modes
07-03-15, 07:40 AM   #1
cazzbr
A Defias Bandit
AddOn Author - Click to view addons
Join Date: Jun 2015
Posts: 3
Help With Frontstring code

so guys, Could you help me with a peace of code i can't figure out whats wrong!
I'm starting to learn lua/xml and can't solve this one by myself.

Code:
               <UI ................>
                          ...
		<Frame .....>
                          ...
                          <Layers>
				<Layer level="OVERLAY">
					<FontString inherits="GameFontNormal" name="HelpMainText">
						<Anchors>
							<Anchor point="TOP" relativeTo="$parent">
								<Offset><AbsDimension x="0" y="-30"/></Offset>
                     				        </Anchor>
						 </Anchors>
						<Scripts>
						HelpMainText:SetText("teste");
						</Scripts>
					</FontString>
				</Layer>
		</Layers>
              </Frame>
          </UI>
The text setted under the script just doesn't show up, if I use the text attribute at the frontstring, like this:
Code:
<FontString inherits="GameFontNormal" text="teste">
It works, so I think the problem is within the script part of the code.

I can't use the text attribute cuz I need a variable to be displayed on this fontstring

Any ideas?
  Reply With Quote
07-03-15, 08:43 AM   #2
cazzbr
A Defias Bandit
AddOn Author - Click to view addons
Join Date: Jun 2015
Posts: 3
Got it working!

The problem was the <scripts> can't be placed inside of a <layers> tag so, this solved the issue!
Code:
 <UI ................>
                          ...
		<Frame .....>
                          ...
                          <Layers>
				<Layer level="OVERLAY">
					<FontString inherits="GameFontNormal" name="HelpMainText">
						<Anchors>
							<Anchor point="TOP" relativeTo="$parent">
								<Offset><AbsDimension x="0" y="-30"/></Offset>
                     				        </Anchor>
						 </Anchors>
					</FontString>
				</Layer>
		</Layers>
        	<Scripts>
                      <OnShow>
			HelpMainText:SetText("teste");
                      </OnShow>
		</Scripts>
              </Frame>
          </UI>
also needed to add the <OnShow> </OnShow> to trigger the event

Last edited by cazzbr : 07-03-15 at 08:45 AM.
  Reply With Quote
07-03-15, 01:24 PM   #3
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,323
The Scripts tag is a list of handlers to run accordingly to which event it's associated with. For example, adding the OnShow tag registers the Lua code contained to run when the frame is shown.

To avoid problems with the default UI and other addons, it's customary to prefix the name of your globals with the name of your addon. This includes names of any and all UI objects you create.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 07-03-15 at 01:33 PM.
  Reply With Quote
07-03-15, 05:20 PM   #4
cazzbr
A Defias Bandit
AddOn Author - Click to view addons
Join Date: Jun 2015
Posts: 3
Originally Posted by SDPhantom View Post
The Scripts tag is a list of handlers to run accordingly to which event it's associated with. For example, adding the OnShow tag registers the Lua code contained to run when the frame is shown.

To avoid problems with the default UI and other addons, it's customary to prefix the name of your globals with the name of your addon. This includes names of any and all UI objects you create.
Thank you for the advise! I'll change the frontstring name to something more specific!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Help With Frontstring 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