View Single Post
03-05-15, 07:51 AM   #35
Dorwido
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Apr 2006
Posts: 54
Bei sowas wie Standardeinstellung finde ich übrigens Metatabellen recht handlich:

Code:
local defaultconf = {["GlobalConf"]=true,["TimeOnMission"]=true,["CounterTraits"]=true,["AutoPlace"]=true,["ShowTimeLeft"]=true,["FollowerRequired"]=true,["QuickAssign"]=true,["GoldExpShow"]=true,
					["HideAlert"]=false,["ShowCounterFollower"]=true,["ShowItemlevelFollower"]=true};

local metatable = {};

metatable.__index = function( inTable, inKey )
  value = defaultconf[inKey];
  inTable[ inKey ] = value;
  return value;
end

setmetatable(GarrisonMissonEnhancedGlobalConfig,metatable);
Das ist ne auszug aus eines meiner addons, GarrisonMissonEnhancedGlobalConfig ist dabei die savedvariable, wenn ich nun aufrufe GarrisonMissonEnhancedGlobalConfig["TimeOnMission"] und das existiert nicht in der saved variable dann wird die standardeinstellung übernommen, so kann man problemlos die standard config erweitern ohne das man in der savedvariable checken muss ob die neue option existiert oder nicht und wenn nicht hinzufügen.
__________________
Auction Analytics
http://www.wowauction.org/
  Reply With Quote