Transforming ".xml" to ".lua"
Hello friends,
I'm having trouble turning a ".xml" code ".lua". XML code is ... 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"> |
As far as I know you can't create templates in code.
The rest can be gleaned from browsing the wowpedia site for script code examples. Here is the HOWTO page that provides a few examples of what you might want to do in addons, there are a few frame related examples which will hopefully get you started. https://wow.gamepedia.com/HOWTOs And this link gets you to the CreateFrame page with some additional examples: https://wow.gamepedia.com/API_CreateFrame Is there a reason you need this in lua format ? |
There is nothing wrong with using XML. If someone else has already created a template you want to use then it's a waste of effort duplicating it in any fashion. Once the widget has been created, it all ends up being the same in-game no matter the method used "read its parts and glue it together".
That said, you can use lua functions to build up widgets just as you would in XML. The "virtual" attribute means "Don't create unless specifically used" just like a function does nothing unless called. Lua Code:
|
In certain narrow cases, XML is 'mandatory' if you need to absolutely need to create an XML template. Examples would be pins on the 8.0.1 world map; I don't think that can be done without an XML file (that is just three lines long).
Otherwise... you just have to go from this paradigm: Code:
<Frame name="MyTemplate" virtual="true" hidden="true"> To this one: Lua Code:
But I would echo Fizzlemizz's remarks... there's nothing wrong with leaving something in XML if its already done. Therefore, I would only advise converting it to Lua if you were making a more substantial change in the process. |
The only time you need to consume an xml template is if you require something to work with the secure environment but that can be done in xml or lua.
Intrinsics would need to be created in XML but calling a function mimics doing that also. |
I never thought of templates in xmls as the equivalent of functions that create frames .. *doh* ..
However, although I can't find the source, I am sure I read somewhere that xml files load faster than lua files. Of course I may have imagined it rofl. But it did make me convert some of my rewritten addons to xml based frames with lua handling the functionality. Whether small addons will notice the difference if this is true, I am sure bigger addons will. |
Optimised for XML in 2004 and 2020, the noticeable difference is probably minimal these days, unless you have something creating lots frames at runtime. The largest single "batch" of frames are created before you see your character in-game.
|
"The only time you need to consume an xml template"
--- It can also be the case if you are interfacing with Blizzard's code that assumes a template. For example, the world map will acquire pins using the name of the template for each pin type. Of course, you could build your own world map that overrides this -- but that's a lot more work! So I guess I cannot fairly say the XML is 'mandatory' but perhaps 'most appropriate' for certain situations. |
To create template in Lua, we should use classes, it's not a simple job to fulfill all requirements.
I can do that with my PLoop and Scorpio Lib, but normally only authors with full OOP background can follow that. So this is only an example for the first two template. Lua Code:
The doc can be found at github.com/kurapica/Scorpio, if you want give it a try. |
All times are GMT -6. The time now is 06:49 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI