Thread Tools Display Modes
06-24-16, 11:44 AM   #1
ulfryc
A Murloc Raider
Join Date: Jun 2016
Posts: 4
How to access local namespace of other addon?

AddOns can access an addon local namespace via the following syntax:
Code:
local addon, ns = ...
The local namespace of the addon is then accessible in the ns variable for all lua files of the addon.
(A thread that explains this functionality.)

How can another addon access this local namespace? I have added the addon I wan't to modify as a dependency but I'm not sure how to access it's local namespace without manipulating it's code to export that local namespace into a global variable.
  Reply With Quote
06-24-16, 11:46 AM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
You can't. It's local to that addon. You can only access globals of other addons.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
06-24-16, 11:51 AM   #3
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
You can't, because it is precisely as you described: a variable local to the AddOn that created it. The variable is not in the global space.

It might be easier to answer if we knew what you wanted to accomplish.
  Reply With Quote
06-24-16, 11:57 AM   #4
ulfryc
A Murloc Raider
Join Date: Jun 2016
Posts: 4
Originally Posted by myrroddin View Post
You can't, because it is precisely as you described: a variable local to the AddOn that created it. The variable is not in the global space.

It might be easier to answer if we knew what you wanted to accomplish.
Ok, since the question is answered, I guess we can go off-topic.

I'm trying to a custom addon that only shows SX_Databar on mouseover. Unfortunately, SX_Databar seems to not export anything into the global namespace, leaving me with no choice but to modify the original code.
  Reply With Quote
06-24-16, 12:20 PM   #5
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,878
All frames are global so if you know the name of the base frame then what you want to do should be possible.

Edit: Assuming showing hiding is all you want to do.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
06-24-16, 12:29 PM   #6
ulfryc
A Murloc Raider
Join Date: Jun 2016
Posts: 4
Originally Posted by Fizzlemizz View Post
All frames are global so if you know the name of the base frame then what you want to do should be possible.

Edit: Assuming showing hiding is all you want to do.
Sadly, the frame I'm interested in does not have a frame name.

Side question: is there are way to make a frame non-interactible? The following is not working for me, unless I change the frames frameType to "Button" instead of "Frame" at it's creation, but documentation tells me "Frame" should be enough.
Code:
local frame = CreateFrame("Frame",nil,UIParent)
frame:HookScript("OnEnter", function()
    ...
end)

Last edited by ulfryc : 06-24-16 at 12:32 PM.
  Reply With Quote
06-24-16, 12:31 PM   #7
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
You don't need to access the local table of SX_DataBar to do that. Type /fstack while mousing over the bar(s) to get their names. Remember those names. If the name is "DataBar1" for example, write this code:
Code:
DataBar1:EnableMouse(true)
DataBar1:SetScript("OnEnter", function ()
    DataBar1:Show()
end)
DataBar1:SetScript("OnLeave", function()
    DataBar1:Hide()
end)
  Reply With Quote
06-24-16, 12:32 PM   #8
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
To disable interaction with a frame, you need FrameName:EnableMouse(false)
  Reply With Quote
06-24-16, 12:40 PM   #9
ulfryc
A Murloc Raider
Join Date: Jun 2016
Posts: 4
Originally Posted by myrroddin View Post
You don't need to access the local table of SX_DataBar to do that. Type /fstack while mousing over the bar(s) to get their names. Remember those names. If the name is "DataBar1" for example, write this code:
Code:
DataBar1:EnableMouse(true)
DataBar1:SetScript("OnEnter", function ()
    DataBar1:Show()
end)
DataBar1:SetScript("OnLeave", function()
    DataBar1:Hide()
end)
Do I even have a chance to find something using /fstack if the framename is not set (nil)?

Concerning :EnableMouse(), exactly what I was looking for, thanks!
  Reply With Quote
06-24-16, 01:03 PM   #10
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
A frame does not need a name to be able to access it. If they haven't named any of their frames whatsoever, and you can't hook any of their functions, you can still access it by looping over the children of its parent and checking for properties which are unique to the frame you're interested in (eg. textures they use, number of children, etc).
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How to access local namespace of other addon?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off