Thread Tools Display Modes
03-19-13, 03:57 PM   #1
fRodzet
A Flamescale Wyrmkin
Join Date: Mar 2013
Posts: 114
H: Why XML and why LUA?

Greetings,

So ive read some books and some topics about LUA and XML. According to most information, LUA should be used for the behavior of an AddOn while XML is used for the Layout(Graphics) - however both can be used for either.

Now my question would be;

In cases like moving a frame, why is
<OnDragStart> self:StartMoving() </OnDragStart>
<OnDragStop> self:StopMovingOrSizing() </OnDragStop>

used over the easy LUA way of doing this?

function MakeMovable(frame)
frame:SetMovable(true)
frame:RegisterForDrag("LeftButton")
frame:SetScript("OnDragStart", frame.StartMoving)
frame:SetScript("OnDragStop", frame.StopMovingOrSizing)
end

now any other frames/buttons/w.e can be moved by just adding like the following code:

local frame = CreateFrame("Button", "UIPanelButtonTemplateTest", UIParent, "UIPanelButtonTemplate")
frame:SetHeight(20)
frame:SetWidth(100)
frame:SetText("Test Button")
frame:ClearAllPoints()
frame:SetPoint("CENTER", 0, 0)
MakeMovable(frame)

putting MakeMovable(frame) now makes the Button i just created Movable in the same manner as the one in XML, however the XML requires that i write it for each frame i create aswell as Register the Event, while this can just call the MakeMovable function.

Maybe i don't quiete get the language yet, or is there an even simpler way to implement moveframes?

Regards,
fRodzet
  Reply With Quote
03-19-13, 04:22 PM   #2
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
You just read the wrong guides
XML is not required and not used by many addons.
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
03-19-13, 04:43 PM   #3
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
I don't use xml in any of my addons simply because I don't know anything about xml coding
__________________
Tweets YouTube Website
  Reply With Quote
03-19-13, 04:53 PM   #4
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
XML is a universal language that can be used in various applications and programming languages, whether to represent data or a graphical layout, like in WoW.

XML in WoW lua allows you to create templates for objects (frames etc), but you can use functions to get similar behaviour in lua. As far as I'm aware there is nothing you can do in XML that you can't replicate in lua (in this case). People who use XML to represent their GUI are often used to doing so in different environments. Habits tend to stick; it's not required to end a line with a semicolon in lua or wrap conditions in brackets, either, but Blizzard still does so in their own code.

TL;DR: Do what you want
  Reply With Quote
03-19-13, 05:37 PM   #5
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
Errors in XML can be a lot harder figure out where as for the most part it's pretty straight forward with LUA errors.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
03-19-13, 06:01 PM   #6
fRodzet
A Flamescale Wyrmkin
Join Date: Mar 2013
Posts: 114
Allright, so if i'm reading the wrong guides.. which do you guys prefer?

Also all the AddOns that i looked at uses .XML for Graphics and minor Script Behaviours - DeadlyBossMods as for example. Ive read the wowprogramming.com book and just started at "Beginning Lua with World of Warcraft AddOns" - both instruct that you can use LUA for everything, but they also both recommend to learn XML as it somehow has some minor advantages in the Graphics section..

Anyways - i'd like a recommendation on where to start:

Should i just go trough wowpedia.org and try to learn it from there, or should i read another book or what do you suggest?
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » H: Why XML and why 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