Custom Addon Framework 2
Filed under Custom Addon Framework
As I mentioned before I've been working on updates for everything, part of these updates include an updated version of CAF.
I've chosen for a new way to build up the framework, to make it easier for me to expand it, without actually have to modify the core of it every time.
Part of this includes that the actual CAF variable used in the code, contains almost no code anymore, but has a system to "dynamicly" load info from the CAF environment, which in terms makes it possible for me to add more functionality, without actually having to add it to the core hardcoded.
Here is the code incase anyone is interested:
I've chosen for a new way to build up the framework, to make it easier for me to expand it, without actually have to modify the core of it every time.
Part of this includes that the actual CAF variable used in the code, contains almost no code anymore, but has a system to "dynamicly" load info from the CAF environment, which in terms makes it possible for me to add more functionality, without actually having to add it to the core hardcoded.
Here is the code incase anyone is interested:
Code:
local allowed = {"VERSION", "debug", "hook", "addons", "net", "log", "store", "other", "lang", "class", "gui", "stools", "_ENV"} -- This will change later on
local meta = {}
function meta.__index(self, key)
if _G.table.HasValue(allowed, key) then
if key == "_ENV" then
return ENV -- The CAF environment
end
return ENV[key] -- The CAF environment
end
return nil
end
function meta.__newindex(self, key, value)
return false
end
function meta.__concat(self, str1, str2)
if str1 == self then
return str1:__tostring()..str2
else
return str1..str2:__tostring()
end
end
function meta.__tostring(self)
return "CAF "..VERSION
end
local obj = {}
_G.setmetatable( obj, meta )
_G.CAF = obj;
Aug22