View Single Post
03-29-24, 10:40 AM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,938
Yep, looks like it.

I use
Lua Code:
  1. local addonName, addonTable = ...
at the top of each of my lua files and give them their own sub table for their functionality and data.

For example - if I were to have my own ButtonManager for some reason I could have something like this

Lua Code:
  1. addonTable.ButtonManager = {}

And then I could create addon wide functions like this
Lua Code:
  1. addonTable.ButtonManager.Create = function(...)
  2. end


I still use the regular local variables and functions if no other file needs to access it.
Or global functions if I want external addons access to certain variables or functions - uniquely named of course and validated

You could simplify the addonTables accessors as follows ( using the previous example )

Lua Code:
  1. -- Create the files data table
  2. addonTable.ButtonManager = {}
  3.  
  4. -- Simplify it
  5. local bm = addonTable.ButtonManager
  6.  
  7. -- Use it
  8. bm.Create = function(...)
  9. end

But I only do that if it's more than 5/10 lines worth of copying and pasting of the table.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote