View Single Post
01-04-23, 11:14 AM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,327
Originally Posted by pstatix View Post
As I went about searching for documentation, pretty much everything points at the various WoW-wiki sites. While this is extensive and can get you started, I've already fallen into several rabbit holes chasing down how it all works.
Long story short. It's been almost 20 years. Direct word from Blizzard about how the process works has been lost to time long ago. The best you can get now is from WoWPedia, which is the successor to the old WoWWiki.



Originally Posted by pstatix View Post
1. No official Blizzard docs, so how was the AddOn load sequence discovered?

The Interface/AddOns directory seems straight forward, but there is nothing in the WoW root directory, or officially provided by Blizzard that indicates "Create an AddOns folder and place a .toc, .xml/.lua file(s) in it and an AddOn will be loaded". So how/when did the load process for AddOns get exposed?
I can't say for sure what was the starting point. Even when I got started back in WoW's first year, we had already migrated to "peek at someone else's code and see what they did".



Originally Posted by pstatix View Post
2. FrameXML and loading XML to Lua, but how?

Following the "discovery" mindset of the first question, it would seem that WoW has some sort of XML to Lua parser? We can set references to other functions defined in a .lua to an objects tags (such as <OnLoad>) and those functions are injected to the tables of the instantiated XML layouts.
The XML parser doesn't "convert" anything into Lua. All UI objects are exposed as fresh tables with a userdata "reference" value stored at index zero and a shared metatable assigned according to the created UI object. The actual UI object resides in C.

Originally Posted by pstatix View Post
I want to make sure I understand that every addon is a root Frame (typically) and the XML is in fact being parsed by some loader and generating Lua objects.
A frame is just an object an addon can make. It isn't part of what defines an addon.



Originally Posted by pstatix View Post
3. Lua 5.1, but not really?

In trying to load multiple files, I initially gave a shot to the "require" keyword, only to find that its not supported. Several Google's lead me to some StackOverflow posts that indicated WoW uses a restricted version of the Lua 5.1 compiler/environment.
This is Lua's nature as an extension language. The host program defines which libraries are made available. It is Lua, but the debug, io, os, and package libraries are disabled. package being the one that provides require(), which is a function, not a keyword. loadfile() and dofile() are gone as well. All this is for obvious security reasons.

As for loading multiple files, just list all of them in the ToC file in your preferred loading order.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 01-04-23 at 11:16 AM.
  Reply With Quote