Thread Tools Display Modes
07-13-07, 04:12 PM   #1
sAlAmAnDeR
A Murloc Raider
Join Date: Jul 2007
Posts: 4
Difference between this XML and Lua

I'm trying to convert some of the code I've already written from XML to Lua, to get rid of the unnessary global variables created and also so I can make a wrapper class which can dynamically create the style of frames that I want. So I have an XML file which looks like this:
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= "ClassBigFrame" parent="UIParent" toplevel="true" movable="true" hidden="false">
		<Size x="100" y="100"/>
		<Anchors>
			<Anchor point="CENTER"/>
		</Anchors>
		<Backdrop bgFile="Interface\Tooltips\UI-Tooltip-Background"
                          edgeFile="Interface\Tooltips\UI-Tooltip-Border" tile="true">
            	<EdgeSize>
             		<AbsValue val="16"/>
            	</EdgeSize>
            	<TileSize>
            		<AbsValue val="16"/>
           	</TileSize>
            	<BackgroundInsets>
            		<AbsInset left="5" right="5" top="5" bottom="5"/>
            	</BackgroundInsets>
         	</Backdrop>
	</Frame>
</Ui>
I've tried to convert it to a Lua file which looks like this:
Code:
frame = CreateFrame("Frame","ClassBigFrame",UIParent)
frame:SetMovable(true)
frame:SetToplevel(true)

frame:SetBackdrop( {
                bgFile = "Interface\Tooltips\UI-Tooltip-Background",
                edgeFile = "Interface\Tooltips\UI-Tooltip-Border",
                tile = true, tileSize = 16, edgeSize = 16,
                insets = { left = 5, right = 5, top = 5, bottom = 5 }
                } )

frame:SetWidth(100)
frame:SetHeight(100)
frame:SetPoint("CENTER")

frame:Show()
They should both do the same thing, but the XML creates a visible tooltip-like window in the middle of the screen, and the Lua file fails to do that (nothing is visible at all). I know that it is getting processed and the interface thinks its visible since if I add a text string as a child in both cases, I get the text floating in the middle of the screen in the Lua file. So what's the difference between the way these two files are handled?
  Reply With Quote
07-16-07, 05:51 AM   #2
Fayen
A Murloc Raider
 
Fayen's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2007
Posts: 9
Maybe either:

frame:SetHidden(false) or frame:SetVisibility(true)?
  Reply With Quote
07-16-07, 06:57 AM   #3
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Frames created by CreateFrame are shown by default.

The symbol \ is used to escape strings.

Code:
frame:SetBackdrop( {
                bgFile = "Interface\Tooltips\UI-Tooltip-Background",
                edgeFile = "Interface\Tooltips\UI-Tooltip-Border",
                tile = true, tileSize = 16, edgeSize = 16,
                insets = { left = 5, right = 5, top = 5, bottom = 5 }
                } )
Should be changed into:
Code:
frame:SetBackdrop( {
                bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
                edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
                tile = true, tileSize = 16, edgeSize = 16,
                insets = { left = 5, right = 5, top = 5, bottom = 5 }
                } )
you can also use:
Code:
frame:SetBackdrop( {
                bgFile = [[Interface\Tooltips\UI-Tooltip-Background]],
                edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]],
                tile = true, tileSize = 16, edgeSize = 16,
                insets = { left = 5, right = 5, top = 5, bottom = 5 }
                } )
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Difference between this XML and Lua


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