How to create a Template using lua?
Hi there guys.
Pretty much every guide i read and learned includes XML, however nowadays everyone prefers/recommends using lua only. Creating a Template i XML is rather simple, however i would like to learn how to create one in lua.. I searched the web abit but couldn't seem to find any guides on how to do so. Can anyone give me an example of a Template made with lua.. Ty :) |
Quote:
|
Quote:
Well it was worth the try.. then imma stick to creating frames etc in lua and keep the xml file as low as possible by only creating templates in xml. |
Quote:
|
Quote:
Creating Templates in XML is easy anyways, but for longer codes i think XML gets really messy and adding comments (<!-- xxx -->) in XML doesn't seem to make it more readable to me. |
Quote:
|
Couldn't you create a function that creates the frame and then call on that function every time you create such a frame?
Lua Code:
|
Quote:
|
Quote:
|
Quote:
Ill tell you if it works :) |
Quote:
However, iirc, if you want to create secure frames/buttons you need to use XML. |
Quote:
I'm fairly sure you don't even need to use XML for secure stuff either. |
XML is not required for secure buttons/frames. You can use templates (which are xml).
http://www.wowpedia.org/SecureActionButtonTemplate |
1 Attachment(s)
The only time you need to use XML is if you are creating secure templates (virtual frames), and the only time you need to do that is if you are working with the secure header system -- for example, setting up a secure header for party frames where each unit frame will include an attached child unit frame for the party member's pet. See attached awesome MSPaint drawing for a better explanation.
|
Quote:
|
Quote:
|
Template Named: "MyCloseButtonTemplate"
In Lua: Code:
NoTemplate = CreateFrame Code:
<Button name="MyCloseButtonTemplate" virtual="true"> |
Nifty. Are you sure that this is taint-secure?
|
It overwrites the global CreateFrame function with an insecure function, so it will definitely cause taint. I'd imagine this would cause major problems with the default raid frames, and probably any addons that use group headers, when someone joins your group in combat, for example.
There's not really any reason to fake a named template like that anyway, even if it could be done securely. Just write a standard factory function, as shown earlier in the thread. |
Quote:
Templates are virtual xml frames and inheriting those frames is just copying their properties and scripts to your frame. I am using my own function to create frames that allows me to customize my frames just like inheriting xml templates and "templates" are additional lua commands to the newly created frame. When you create "SimpleHTML" frame, you can even specify to automatically add font: Lua Code:
I am beginner in lua and xml and I like this more than templates in xml. :( You can inherit more than just one template. :o |
All times are GMT -6. The time now is 05:37 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI