Proposal - Embeddable oUF Extension Mods
Lately I've been looking in to embedding oUF into my layout to make a self-contained addon. Haste supports this quite well with his metadata trick at the top of each file in oUF:
oUF.lua: Code:
local parent = debugstack():match[[\AddOns\(.-)\]] All the files in oUF\elements: Code:
local parent = debugstack():match[[\AddOns\(.-)\]] MyAddon\MyAddon.toc: Code:
## X-oUF: oUFembed Then, at the top of my layout file, I can reference the embedded oUF like this: MyAddon\layout.lua: Code:
local oUF = oUFembed The problem comes when I want to embed an oUF extension written by someone else. Let's use as an example oUF_Banzai by Rabbit. If I wanted to embed it into my addon, it will fail. Oh, it won't crash, but it also won't work. Why? Because it makes an assumption that oUF is installed as an independent addon, and that it is published on the global symbol oUF and not oUFembed as I did above. The first non-comment line of code enforces it like this: oUF_Banzai.lua: Code:
if not oUF then return end If the top lines in the oUF_Banzai were as follows instead of the simple check used currently, the embedded version would work: Proposed oUF_Banzai.lua: Code:
local parent = debugstack():match[[\AddOns\(.-)\]] So what I'd like to propose / ask is that all oUF extension authors add these four lines of code to the top of their extensions. It makes it easier to embed and causes no harm to your existing code. Question/comments appreciated. |
I already do this in oUF_Fader (at least I think I do).
Although I don't like your generic global name, why not use <MyAddon>oUF instead of oUFembed, as your current name could cause some conflicts at a later date. |
Quote:
Thanks for calling that out. |
Quote:
oUF_Fader.lua Line 1: Code:
if not oUF then return end |
All my plug-ins support embedding.
|
Quote:
In both oUF_BarFader and oUF_RuneBar you reference the global symbol oUF (bad) without any assert or check (good). In an embedded scenario the global oUF symbol probably doesn't exist unless the layout author republished it into global scope. The part you're missing is having this at the top of the lua file: Code:
local parent = debugstack():match[[\AddOns\(.-)\]] |
Meh I did it for my local version, I just forgot to update it :P.
|
This should be updated to the new system.
|
Within oUF_HealComm4 I currently use the following which if safe for servers running patch 3.2.X and patch 3.3:
Code:
local oUF a version that supports only servers running patch 3.3 would be: Code:
local parent, ns = ... I think all current live servers run patch 3.3. It just depends on what patch the China servers will be at if they ever get running again. |
Last time I talked to someone playing on China they were still on TBC, but that was around the start of November. Most of the people who care aren't playing on the Chinese servers anyway.
Anyway, just do: Lua Code:
|
All times are GMT -6. The time now is 07:39 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI