Quantcast
Creating Controls: Lua vs. XML? - ESOUI
Thread Tools Display Modes
05/08/14, 04:04 PM   #1
Roupine
Join Date: May 2014
Posts: 18
Question Creating Controls: Lua vs. XML?

Hey Folks,

So far with my addons, I've been creating all of the control elements within the Lua code instead of XML. Is there a downside to doing this compared to using XML? I've noticed that I don't seem able to create a virtual control via Lua, but I don't quite understand the benefit of a virtual control to begin with. The only reason I've had to create a virtual control in XML is for use with ZO_ObjectPool. Quite frankly, I'm keen to just write my own object pool anyway.

Also what I've found is that the error messages are a lot more informative when you mess up the Lua code compared to the XML (ie. "You're missing a '=' at this if statement on this line" vs. "YOUR XML IS BAD AND YOU SHOULD FEEL BAD")

In what sort of situations would I want to create UI controls in XML vs. Lua?
  Reply With Quote
05/08/14, 04:40 PM   #2
CrazyDutchGuy
 
CrazyDutchGuy's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 89
If you have a static layout, then you would put it in XML

If you have a dynamic layout, then you would put it in LUA

It can be a combination of both even.
  Reply With Quote
05/08/14, 09:47 PM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 651
I prefer to use Lua over XML. It is easier to read (for me, at least), you don't have to give all your controls a global reference/name, and the error handling is far superior.

The only thing you need XML for is to create a template (this is what virtual means). But, even then, you could always use a factory function to create your frames from a "template" instead...
  Reply With Quote
05/09/14, 09:54 AM   #4
Iyanga
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 185
Originally Posted by Roupine View Post
In what sort of situations would I want to create UI controls in XML vs. Lua?

I think there was a thread about this somewhere already.

Traditionally, you keep display logic and business logic separate, as you don't want that the web designer messes with your database and the web designer for sure doesn't want that you pick the Comic Sans font for displaying the content.

The ability to change the presentation without the functionality has other benefits, like for example, the ability to display a printer friendly version without the need to create a new functionality.

Of course, in this environment of addon development all those traditional benefits are not really important. You need to use a /reloadui, no matter whether you change the XML or the LUA file and the addon author is designer and coder together, too.

So here it's really more a matter of personal preference.

I try to stick everything I can into the XML, as I'm used to the traditional approach.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Creating Controls: Lua vs. XML?

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