View Single Post
08-19-15, 11:48 AM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Well, I'm not sure "hooks" are actually what you're asking about, and you certainly shouldn't create a function in one file in your addon and hook it in another. Hooks are for when you want to modify something in Blizzard code or another addon. If you're writing your own code, just write it the way you want it in the first place.

That said, to share something between files in your addon, just add it to your addon's private table; you've named it "ns" in your code:

AddOn1\file1.lua
Lua Code:
  1. local addon, ns = ...
  2. local frame = CreateFrame("Frame")
  3. ns.frame = frame

AddOn2\file2.lua
Lua Code:
  1. local addon, ns = ...
  2. local frame = ns.frame
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote