WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   Access "AddOn namespace" (addonName, addonTable = ...) from outside? (https://www.wowinterface.com/forums/showthread.php?t=58386)

fuba 11-17-20 08:23 AM

Access "AddOn namespace" (addonName, addonTable = ...) from outside?
 
Hi there,

i got a question about AddOn namespace or more specific the "addonTable".

What exactly i mean?
Some AddOns did not set there AddOn Table for Global Access (becasue?! Reasons!)

Like this:
Lua Code:
  1. local addonName, addonTable = ...
or this:
Lua Code:
  1. local _, Engine = ...

I know i can edit this AddOn(s) manually by adding a Global Variable like:
Lua Code:
  1. local addonName, addonTable = ...
  2. _G[addonName] = addonTable
or
Lua Code:
  1. local _, Engine = ...
  2. _G.MyAddOnEngine = Engine

BUT there must be another way, without "touching" the original addon, right?

I found some Threads here that say "just set "Dependencies" in your TOC file for the AddOn and you can access it.
But i cant get it work!

Is there anything i look over? ^^

Maybe someone can help!

greetings,
fuba

Fizzlemizz 11-17-20 09:51 AM

The addition of the addon table (Namespace if you will) was exactly to avoid the situation of having to create functions and data as global if you only wanted to share it between other modules in your addon. If an addon only has one .lua file or doesn't have code to share within the addon, it doesn't need to use the addon table.

That's the authors choice.

The only way you can access addon table data from other addons is if you edit the code and make a reference to it in the global table, as you showed or if the author has placed a reference to it in the global table or in another table that is also global (like a frame).

fuba 11-17-20 11:15 AM

Quote:

Originally Posted by Fizzlemizz (Post 337600)
The addition of the addon table (Namespace if you will) was exactly to avoid the situation of having to create functions and data as global if you only wanted to share it between other modules in your addon. If an addon only has one .lua file or doesn't have code to share within the addon, it doesn't need to use the addon table.

That's the authors choice.

The only way you can access addon table data from other addons is if you edit the code and make a reference to it in the global table, as you showed or if the author has placed a reference to it in the global table or in another table that is also global (like a frame).

Ok, thanks :/


All times are GMT -6. The time now is 08:04 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI