View Single Post
08-26-10, 01:57 PM   #8
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
You could also handle your SV-table defaults with some metatable magic. That's the way I normally do it:

Code:
local defaults = {
    enemy = true,
    friend = true,
}

function CNames:ADDON_LOADED(event)
    CNames_Options = CNames_Options or {}
    setmetatable(CNames_Options, { __index = defaults})
    ...
end
The metatable's __index works as following: if some value in your table is 'nil', it automatically provides the value in the default table. So, you would handle it exactly the same currently, but won't have to think lots about booleans when defining new default values
__________________
« Website | GitHub »

Oh hai!
  Reply With Quote