diff --git a/src/class.lua b/src/class.lua index 026458f..beebe56 100644 --- a/src/class.lua +++ b/src/class.lua @@ -117,9 +117,13 @@ function module.init(shared) end local tween = value.tvalue; local from = value.fvalue; + local add = value.avalue; -- adding event function local function regFn(_,newValue,key) + if add then + newValue = newValue + add; + end if from then newValue = from[newValue]; end diff --git a/src/store.lua b/src/store.lua index d0eb64d..663bfec 100644 --- a/src/store.lua +++ b/src/store.lua @@ -110,6 +110,9 @@ function module.init(shared) from = function (s,value) return setmetatable({fvalue = value},{__index = s}); end; + add = function (s,value) + return setmetatable({avalue = value},{__index = s}); + end; }; registerClass.__index = registerClass; @@ -133,6 +136,10 @@ function module.init(shared) end end function store:__call(key,func) + local last = self.__self[key]; + if last and type(last) == "table" and getmetatable(last) == registerClass then + return last; + end local register = self.__reg[key]; if not register then register = setmetatable({