Thread Tools Display Modes
07-14-09, 09:25 AM   #1
Drshow
A Cyclonian
 
Drshow's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 49
Question

was hoping someone could post a simple sample of "how to" use plain text that is stored in a lua file, to render into xml frame. Localization of sorts. The text listed in the text="" part, i would like to localize in the lua file.

sample of what i have:
Code:
<FontString name="$parentLabel" font="Fonts\FRIZQT__.TTF" text=" This is a Frame Label.  Adding text to a Label seems to be very limited." justifyV="TOP" justifyH="LEFT">
                  <Anchors>
                    <Anchor point="TOPLEFT" />
                    <Anchor point="BOTTOMRIGHT" />
                  </Anchors>
                  <FontHeight>
                    <AbsValue val="12" />
                  </FontHeight>
                  <Color r="1" g="0.8196079" b="0" />
                  <Shadow>
                    <Color r="0" g="0" b="0" />
                    <Offset>
                      <AbsDimension x="1" y="-1" />
                    </Offset>
                  </Shadow>
                </FontString>
__________________

Last edited by Drshow : 07-14-09 at 10:24 PM. Reason: Differnt wording.
  Reply With Quote
07-14-09, 10:04 AM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,935
Not quite sure if I understood you right there but I am assuming you meant how to get text displayed on a frame in lua instead of in xml ?

Here's a segment of one of my addons which are pure lua coding.

Code:
-- Create the Frame itself
local frame = CreateFrame("Frame","MagePorts_Frame",UIParent);
frame:SetWidth(250);        
frame:SetHeight(100);
frame:SetAlpha(1.0);        
frame:SetClampedToScreen(true);
frame:SetPoint("CENTER",UIParent,"CENTER",0,0);
    
-- Create the Portal Title 
frame.PortalTitle = frame:CreateFontString("MagePorts_Frame_PortalTitle", 'ARTWORK', "GameFontNormal");
frame.PortalTitle:SetPoint("TOPLEFT",frame,"TOPLEFT",0,-20);	
frame.PortalTitle:SetText("");
Hopefully that helps you somewhat.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
07-14-09, 09:57 PM   #3
Drshow
A Cyclonian
 
Drshow's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 49
Beautiful example, but not what i was looking for. The text stored in the lua to be displayed in frames on the xml file. Like a localized file in a sense.
__________________
  Reply With Quote
07-14-09, 10:07 PM   #4
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
1. Make sure your lua loads before the xml.
2. Create a fontstring in lua/xml whose parent is the frame you want to display text on.
3. At some point after the fontstring is created, call :SetAllPoints() on it, or otherwise size it the way you want it, for example with a <size> tag.
4. Use :SetText(variableFromTheLuaFile) to set its text. You cannot do this with the "text=" attribute. You have to do it in a Lua function, although that can be within a <Script> tag in XML if you really want to do that.

Last edited by Akryn : 07-14-09 at 10:10 PM.
  Reply With Quote
07-16-09, 11:25 AM   #5
Drshow
A Cyclonian
 
Drshow's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 49
Is there a possibility you can show me an example of this in use

Originally Posted by Akryn View Post
1. Make sure your lua loads before the xml.
2. Create a fontstring in lua/xml whose parent is the frame you want to display text on.
3. At some point after the fontstring is created, call :SetAllPoints() on it, or otherwise size it the way you want it, for example with a <size> tag.
4. Use :SetText(variableFromTheLuaFile) to set its text. You cannot do this with the "text=" attribute. You have to do it in a Lua function, although that can be within a <Script> tag in XML if you really want to do that.

Is there a possiblity you can show me an example of this method being used. I have torn apart alot of addons and am yet to see it in use.
__________________
  Reply With Quote
07-16-09, 08:17 PM   #6
Medii
A Murloc Raider
Join Date: Jul 2009
Posts: 5
Not sure what it is you want to do, but unless you've got a really good reason to use xml you should create the frame, fontstring and set its text with lua only instead.

Everything that can be done in the xml file can be done in lua, and usually much easier and in fewer lines of code.
  Reply With Quote
07-16-09, 08:41 PM   #7
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
Originally Posted by Drshow View Post
Is there a possiblity you can show me an example of this method being used. I have torn apart alot of addons and am yet to see it in use.
I'll write you an example if you tell me what you're trying to do and why you need to do it in XML.
  Reply With Quote
07-17-09, 02:27 AM   #8
Drshow
A Cyclonian
 
Drshow's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 49
Originally Posted by Akryn View Post
I'll write you an example if you tell me what you're trying to do and why you need to do it in XML.
OK here is what im trying to do. Make a sample frame addon with text on frame that is stored in the lua file like a database. Eventually it will be multible pageable frames pulling from an ever growing data base or lua.

Frame = Drshow.xml

Lua = Drshow.lua

Link below is the sample addon im trying to add this to.



http://www.wowinterface.com/download...ions.html#info
__________________

Last edited by Drshow : 07-17-09 at 02:43 AM. Reason: point to link.
  Reply With Quote
07-17-09, 11:58 AM   #9
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,935
Hmm, Am I guessing right that you are trying to build a framework to add multiple addon information into a single addon regardless of who created the initial addon ?

A simple frame can be created easily without xml but that is your choice but as has been pointed out you would need to make sure the lua files holding the data is loaded into memory before the xml file is loaded. You can do this with your own addon but not someone elses as the game loads up ( so I have noticed ) in alphabetical order.

Even without using xml for the frame design you would still get possible problems getting other addons to be loaded before your one unless you give it a higher alphabetical position ( I suspect that is ).
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
07-18-09, 06:36 AM   #10
Drshow
A Cyclonian
 
Drshow's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 49
Originally Posted by Xrystal View Post
Hmm, Am I guessing right that you are trying to build a framework to add multiple addon information into a single addon regardless of who created the initial addon ?


You are guessing incorrect. I just want the text of the frame to come from the lua. I really dont know how else to ask.

Can someone show me an example of -
a frame in xml with all its text, content pulled from lua with settext

in html or php you could use an <include> and put the content on the include page.

maybe it just cant be done

Currently the text is stored in <fontstring text=the text i would like to come from lua is here></fontstring>
in the xml file, i would like the text= text to come from lua instead.
__________________

Last edited by Drshow : 07-18-09 at 06:38 AM. Reason: omg help me ask lol.
  Reply With Quote
07-18-09, 07:09 AM   #11
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,935
Then like the other person said earlier it would be simply the case of making sure that the lua dictionary ( for want of a better term ) is included in the lua before the xml itself.

You should find several simple addons that have an xml/lua duo file set up and it would be simply the case of getting the fontstring section of the xml file to have a script set up to read in the value currently available in the lua. But this can also be done in lua thats why we can't understand why it has to be in xml but either way lets see.

Dictionary.toc
Code:
## Interface: 30000
## Title : Dictionary
## Notes: This AddOn does nothing but display a frame with some text
## Author: My Name
Dictionary.lua
Dictionary.xml
Dictionary.lua
The following is a simple lua file that simply generates a list of words you can access via Dictionary[1], Dictionary[2] etc. The values cannot be local unless there is a non local function returning the list or an element of the list for use outside of the file. This list or function would be available to any addon installed at the same time if they so wished to use it.
Code:
Dictionary = {};
table.insert(Dictionary,"AWord");
table.insert(Dictionary,"AnotherWord");
Dictionary.xml
This specifies a frame that covers a quarter of your UI (regardless to the selected resolution) and centered on the screen.
Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">
   <Frame name="Dictionary_Frame">
     <Size><RelDimension x="0.5" y="0.5"/> </Size>
     <Anchors>
       <Anchor point="CENTER"/>
     </Anchors>
     <Layers>
       <Layer level="ARTWORK">
         <FontString name="$parentFontString" font="Fonts\FRIZQT__.TTF" text="" justifyH="LEFT" justifyV="TOP">
           <Color r="1" g="0.8" b="1" a="1"/>
           <FontHeight>
             <AbsValue val="12"/>
           </FontHeight>
           <Anchors>
             <Anchor point="TOPLEFT" relativeTo="$parent">
               <Offset>
                 <AbsDimension x="20" y="-20"/>
               </Offset>
             </Anchor>
           </Anchors>
        </FontString>
       </Layer>
     </Layers>
     <Scripts>    CAN'T REMEMBER THE FULL FORMAT HERE
       <OnShow>
          self:SetText(Dictionary[1]);          THIS MAY NOT BE CORRECT TEST AND SEE
       </OnShow>
     </Script>
   </Frame>
</Ui>
I don't know whether that will work or not but 95% of that was taken from wowwikis page linked below with the text value set to the value available from the list created in the lua file. It will only make one string though, you would have to repeat the fontstring block for each string you want to display if you want to do it in the xml file. In a lua file you would be able to do similar using a programming loop. But again I am not sure if I have understood you correctly but it is the best understanding of your explanation so far.

In their examples about fontstring it assumes you use lua to set the value in xml and not the other way round so cannot offer another solution for this I'm afraid.
Here's a good place for you to start making xml/lua based addons : http://www.wowwiki.com/Getting_start...writing_addons
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818

Last edited by Xrystal : 07-18-09 at 07:24 AM. Reason: Typing Mistakes ... rofl
  Reply With Quote
07-18-09, 10:10 AM   #12
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
Originally Posted by Drshow View Post
<fontstring text=the text i would like to come from lua is here></fontstring>
As I said:

4. Use :SetText(variableFromTheLuaFile) to set its text. You cannot do this with the "text=" attribute. You have to do it in a Lua function, although that can be within a <Script> tag in XML if you really want to do that.
and a good example of that has already been provided.
  Reply With Quote
07-21-09, 08:33 AM   #13
Drshow
A Cyclonian
 
Drshow's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 49
Thumbs up Ty akryn

Originally Posted by Akryn View Post
As I said:



and a good example of that has already been provided.
Just wanted to thank you for pointing that out to me at first, the purpose of me asking for printed code examples is to provide some lamen usefullness to others getting started in making addons. I understand the value ":settext" but when i first started i did not and in looking at your explaination i thought to myself if i was a beginer i would have no idea what you where talking about.
For most seeing is understanding.
I even tried google'ing various elements of your post to get further info. With no success i realized that an example is in order. I am hoping to add a few more "coded examples of rendering paragraph style text to frames" if you are interested in helping out.
I know there is many ways to achieve this and adding as many example to this post will only add benefit to those starting out with creating addons.
__________________

Last edited by Drshow : 07-21-09 at 08:35 AM. Reason: spelling
  Reply With Quote
07-21-09, 04:17 PM   #14
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,935
Originally Posted by Drshow View Post
Just wanted to thank you for pointing that out to me at first, the purpose of me asking for printed code examples is to provide some lamen usefullness to others getting started in making addons. I understand the value ":settext" but when i first started i did not and in looking at your explaination i thought to myself if i was a beginer i would have no idea what you where talking about.
For most seeing is understanding.
I even tried google'ing various elements of your post to get further info. With no success i realized that an example is in order. I am hoping to add a few more "coded examples of rendering paragraph style text to frames" if you are interested in helping out.
I know there is many ways to achieve this and adding as many example to this post will only add benefit to those starting out with creating addons.
Unfortunately there are only 3 ways of setting text that I am aware of.

Pure Xml :
<FontString name="$parentFontString" font="Fonts\FRIZQT__.TTF" text="PutYourTextHere" justifyH="LEFT" justifyV="TOP">

XmlFromLua :
My Xml/Lua Example shown earlier

Pure Lua :
My Lua Example earlier
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
07-22-09, 06:43 AM   #15
Drshow
A Cyclonian
 
Drshow's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 49
Cool

Originally Posted by Xrystal View Post
Unfortunately there are only 3 ways of setting text that I am aware of.

Pure Xml :
<FontString name="$parentFontString" font="Fonts\FRIZQT__.TTF" text="PutYourTextHere" justifyH="LEFT" justifyV="TOP">

XmlFromLua :
My Xml/Lua Example shown earlier

Pure Lua :
My Lua Example earlier
well i guess there are no tricks up the sleeves of the crafty addon / mod authors. Our job is done here,
lol oh ya and good morning everyone. Coffee is served.
__________________
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » rendering text from lua to xml


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