Edit: Thanks to Vrul who pointed out my error. I've fixed the following code for posterity.
ADDON_LOADED triggers if, as you'd assume, an addon is loaded; this includes Load-On-Demand addons, like Blizzard_AzeriteEssenceUI. I can't recall off hand what other UI objects are LOD but you can reuse the event frame for those as needed; you can check an export of the interface files for the Blizzard_Addons which include Load-On-Demand in their TOC.
You could use LoadAddOn, but loading an addon that you likely won't use for 109 levels on a level 1 is rather pointless; I'd only recommend it if it's a UI object that can be used on any level/class/race.
Lua Code:
local EventFrame = CreateFrame('Frame', nil, UIParent)
EventFrame:RegisterEvent('ADDON_LOADED')
EventFrame:SetScript('OnEvent', function(self, event, name)
if event == 'ADDON_LOADED' then
if name == 'Blizzard_AzeriteEssenceUI' then
--AzeriteEssenceUI
local MAEU = AzeriteEssenceUI
MAEU.ClearAllPoints = function() end
MAEU:SetPoint("TOPRIGHT", MinimapCluster, "BOTTOM", 45, -5)
MAEU.SetPoint = function() end
MAEU:SetMovable(true)
MAEU:SetUserPlaced(true)
MAEU:SetClampedToScreen(true)
local MoveAzeriteEssenceUI = CreateFrame("Frame", nil, MAEU)
MoveAzeriteEssenceUI:SetHeight(15)
MoveAzeriteEssenceUI:ClearAllPoints()
MoveAzeriteEssenceUI:SetPoint("TOPLEFT", MAEU)
MoveAzeriteEssenceUI:SetPoint("TOPRIGHT", MAEU)
MoveAzeriteEssenceUI:EnableMouse(true)
MoveAzeriteEssenceUI:SetHitRectInsets(-5, -5, -5, -5)
MoveAzeriteEssenceUI:RegisterForDrag("LeftButton")
MoveAzeriteEssenceUI:SetScript("OnDragStart", function(self, button)
if button=="LeftButton" and IsModifiedClick()then
MAEU:StartMoving()
end
end)
MoveAzeriteEssenceUI:SetScript("OnDragStop", function(self, button)
MAEU:StopMovingOrSizing()
end)
--AzeriteEssenceUI
end
end
end)
Doing multiple LOD objects:
Lua Code:
EventFrame:SetScript('OnEvent', function(self, event)
if event == 'ADDON_LOADED' then
if name == 'Blizzard_AzeriteEssenceUI' then
--AzeriteEssenceUI
elseif name == 'InsertUINameHere' then
--Mover code for InsertUINameHere
end
end
end)
To export interface files:
- Head over to your WoW install folder and create a shortcut for WoW.exe
- Right-click the WoW shortcut and click "Properties".
- In the "Target" box, add -console while preserving any quotation marks that may be there. This must be placed after the quotation mark; it should look something like "C:/<Path to WoW>/WoW.exe" -- console
- Click "OK".
- Use the shortcut; this is done normally by double-clicking, or clicking once if single-click is enabled.
- At the login screen hit '`'; that's '~' without hitting shift. Follow further instructions here if your keyboard layout doesn't include '`'.
- Input "ExportInterfaceFiles code" without quotes in the console and press enter; it will take a while, I recommend not playing during this time.
- When complete you'll find a folder called BlizzardInterfaceCode in your WoW folder.
- Dig through Blizzard code to your hearts content.