View Single Post
08-16-05, 10:01 AM   #9
Garoun
A Fallenroot Satyr
 
Garoun's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2005
Posts: 25
Great idea on using the localization form of the UnitClass, as you mentioned, saves the need to create localized versions of the same code in this situation.

Originally Posted by Littlejohn

There's no real reason to use global variables for each class though -- and there are good reasons not to: (1) you have to use a special function getglobal() to fetch them, and (2) you've got more global variables to worry about module conflicts. I think this is a little bit cleaner:
Code:
local _, class = UnitClass('player')

Global_options = {'a','b','c'}
Class_options = {
    WARRIOR = {'d','e','f'},
    ROGUE = {'g','h','i'}
}

for k,v in Class_options[class] do
    table.insert(Global_options, v)
end
Ok, still with you and I can see how the psuedo-tables will work and actually think that would be cleaner and easier to maintain for users. I'll have to look at Grayhoof's code in SCT for his custom configs to see if there is a way to work it in without required changes to the main SCT.lua otherwise I'll just have to use tables like he currently does and go with it.


*Note for self when I get home - thinking out loud*
Possibly use the code for the pseudo table to generate the combined global/class variable then, even though kinda redundant, write the combined into the table variable used by SCT. -ponder-

Last edited by Garoun : 08-16-05 at 10:03 AM.
  Reply With Quote