-- Class.lua-- Defines functions and objects required for object modelfunction Class() local ClassContainer = { __Inheritance = {m_Object = {}, m_Next = nil} } local ClassMetaTable = { __index = function(Table, Key) --Check if a table has a key local function HasKey(T, Key) if T[Key] ~= nil then return T[Key] end return nil end --Iterate through the __Inheritance list local function Iter(T, Key) if T == nil then return nil end local x = HasKey(T.m_Object, Key) if x ~= nil then return x end return Iter(T.m_Next, Key) end local x = Iter(Table.__Inheritance, Key) if x == nil then return rawget(Table, Key) end return x end, __newindex = function(Table, Key, Value) rawset(Table.__Inheritance.m_Object, Key, Value) end } setmetatable(ClassContainer, ClassMetaTable) return ClassContainerend