core: don't rely on sane global environment
some addons like to provide a broken _G variable to the global environment breaking every other addon that relies on it if existing. With this commit, make ShaguTweaks no longer re-use the global _G, even if existing.
This commit is contained in:
+24
-1
@@ -1,6 +1,29 @@
|
||||
local _G = _G or getfenv(0)
|
||||
local gfind = string.gmatch or string.gfind
|
||||
|
||||
ShaguTweaks.GetExpansion = function()
|
||||
local _, _, _, client = GetBuildInfo()
|
||||
client = client or 11200
|
||||
|
||||
-- detect client expansion
|
||||
if client >= 20000 and client <= 20400 then
|
||||
return "tbc"
|
||||
elseif client >= 30000 and client <= 30300 then
|
||||
return "wotlk"
|
||||
else
|
||||
return "vanilla"
|
||||
end
|
||||
end
|
||||
|
||||
ShaguTweaks.GetGlobalEnv = function()
|
||||
if ShaguTweaks.GetExpansion() == 'vanilla' then
|
||||
return getfenv(0)
|
||||
else
|
||||
return _G or getfenv(0)
|
||||
end
|
||||
end
|
||||
|
||||
local _G = ShaguTweaks.GetGlobalEnv()
|
||||
|
||||
local gradientcolors = {}
|
||||
ShaguTweaks.GetColorGradient = function(perc)
|
||||
perc = perc > 1 and 1 or perc
|
||||
|
||||
Reference in New Issue
Block a user