--[[ Automatic Persistent Subtable Settings ]]-- APSS_New_newindex = function(t,k,v) if type(v) == "table" then if not (getmetatable(v) or {}).__hasNewMT then local newMT = {__newindex = APSS_New_newindex, __oldIndex = (getmetatable(v) or {}).__newindex, __parentTable = t, __parentKey = k, __hasNewMT = true} for x, y in pairs(getmetatable(v) or {}) do if x ~= "__newindex" then newMT[x] = y end end setmetatable(v, newMT) end end rawset(t,k,v) local tMT = getmetatable(t) or {} if tMT.__parentTable then getmetatable(tMT.__parentTable).__newindex(tMT.__parentTable, tMT.__parentKey, t) end if tMT.__oldIndex then tMT.__oldIndex(t,k,v) end end APSS_Main_newindex = function(t,k,v) if type(v) == "table" then if not (getmetatable(v) or {}).__hasNewMT then local newMT = {__newindex = APSS_New_newindex, __oldIndex = (getmetatable(v) or {}).__newindex, __hasNewMT = true} for x, y in pairs(getmetatable(v) or {}) do if x ~= "__newindex" then newMT[x] = y end end setmetatable(v, newMT) end end rawset(t,k,v) local tMT = getmetatable(t) or {} if tMT.__oldIndex then tMT.__oldIndex(t,k,v) end end function SetMetatables(t, p, k) if type(t) == "table" then for k,v in pairs(t) do if type(p) == "table" or p == 2 then SetMetatables(v, t, k) elseif p == 1 then SetMetatables(v, 2) end end if not (getmetatable(t) or {}).__hasNewMT then if type(p) == "table" then local newMT = {__newindex = APSS_New_newindex, __oldIndex = (getmetatable(t) or {}).__newindex, __parentTable = p, __parentKey = k, __hasNewMT = true} for x, y in pairs(getmetatable(t) or {}) do if x ~= "__newindex" then newMT[x] = y end end setmetatable(t, newMT) else local newMT = {__newindex = APSS_New_newindex, __oldIndex = (getmetatable(t) or {}).__newindex, __hasNewMT = true} for x, y in pairs(getmetatable(t) or {}) do if x ~= "__newindex" then newMT[x] = y end end setmetatable(t, newMT) end end end end local newMT = {__newindex = APSS_Main_newindex, __oldIndex = (getmetatable(a) or {}).__newindex, __hasNewMT = true} for x, y in pairs(getmetatable(Settings) or {}) do if x ~= "__newindex" then newMT[x] = y end end setmetatable(Settings, newMT) SetMetatables(Settings, 1)