--[[ ]] local userdata = {} local Register = {} function Register:del(key) userdata[self.namespace][key] = nil end function Register:get(key) if userdata[self.namespace][key] ~= nil then return userdata[self.namespace][key] else return false end end function Register:set(key, value) userdata[self.namespace][key] = value return true end function Register:new() if namespace == nil then namespace = ‘default‘ end if userdata[namespace] == nil then userdata[namespace] = {} end local instance = { namespace = namespace, del = self.del, get = self.get, set = self.set } setmetatable(instance, Register) return instance end function Register:__newindex(key, value) if key ~= nil and value ~= nil then userdata[self.namespace][key] = value end end function Register:__index(index) local out = rawget(userdata[self.namespace], index) if out then return out else return false end end return Register
时间: 2024-12-18 12:46:01