Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local InitializeFuncs = script:GetChildren()
- script:ClearAllChildren()
- local Apollo = newproxy(true)
- local ApolloMeta = getmetatable(Apollo)
- ApolloMeta.__metatable = "Locked for security reasons."
- local rawprint = print
- print = function(...) if _G.ApolloDebug then rawprint(unpack({...})) end end
- local TableMeta = {}
- TableMeta.__metatable = "Locked for security reasons."
- TableMeta.__index = function(self,ind) local val = rawget(self,ind) print("Get:",self,ind,val) if type(val) ~= nil then return val end end
- TableMeta.__newindex = function(self,ind,val) print("Apollo : Set:",self,ind,val) rawset(self,ind,val) end
- local ApolloIndex = {}
- setmetatable(ApolloIndex,TableMeta)
- local Storage = {}
- setmetatable(Storage,TableMeta)
- do
- local function HandleInit(InitModule,InitData)
- if InitData.Meta then
- if not ApolloMeta[InitData.Meta] then
- if InitData.Function then
- rawset(ApolloMeta,InitData.Meta,function(self,...) return InitData.Function(ApolloIndex,unpack({...})) end)
- else
- warn("Apollo : Apollo meta initialization failure due to missing function:",InitData.Meta)
- end
- else
- warn("Apollo : Apollo meta initialization failure due to pre-existing meta:",InitData.Meta)
- end
- else
- if InitData.Function then
- local RunSucc,RunErr = pcall(function() return InitData.Function(Apollo,ApolloIndex,Storage) end)
- if not RunSucc then
- warn("Apollo : Apollo initialization failure when attempting to execute:",InitModule.Name,"-",RunErr)
- end
- end
- end
- end
- local LoadOrder = {}
- LoadOrder.Pre = {}
- LoadOrder.Before_Meta = {}
- LoadOrder.Meta = {}
- LoadOrder.After_Meta = {}
- LoadOrder.After_Core = {}
- LoadOrder.Services = {}
- LoadOrder.After_Services = {}
- LoadOrder.Unordered = {}
- LoadOrder.Final = {}
- for i=1,#InitializeFuncs do
- local InitModule = InitializeFuncs[i]
- if type(InitModule) == "userdata" and InitModule:IsA("ModuleScript") then
- local InitSucc,InitErr = pcall(function() return require(InitModule) end)
- if not InitSucc then
- warn("Apollo : Apollo initialization failure:",InitErr)
- else
- local InitData = InitErr
- if InitData.Meta then
- table.insert(LoadOrder.Meta,{InitModule,InitData})
- else
- if InitData.LoadOrder and LoadOrder[InitData.LoadOrder] then
- table.insert(LoadOrder[InitData.LoadOrder],{InitModule,InitData})
- else
- table.insert(LoadOrder.Unordered,{InitModule,InitData})
- end
- end
- end
- end
- end
- for i=1,#LoadOrder.Pre do
- local Load = LoadOrder.Pre[i]
- HandleInit(Load[1],Load[2])
- end
- for i=1,#LoadOrder.Before_Meta do
- local Load = LoadOrder.Before_Meta[i]
- HandleInit(Load[1],Load[2])
- end
- for i=1,#LoadOrder.Meta do
- local Load = LoadOrder.Meta[i]
- HandleInit(Load[1],Load[2])
- end
- for i=1,#LoadOrder.After_Meta do
- local Load = LoadOrder.After_Meta[i]
- HandleInit(Load[1],Load[2])
- end
- for i=1,#LoadOrder.After_Core do
- local Load = LoadOrder.After_Core[i]
- HandleInit(Load[1],Load[2])
- end
- for i=1,#LoadOrder.Services do
- local Load = LoadOrder.Services[i]
- HandleInit(Load[1],Load[2])
- end
- for i=1,#LoadOrder.After_Services do
- local Load = LoadOrder.After_Services[i]
- HandleInit(Load[1],Load[2])
- end
- for i=1,#LoadOrder.Unordered do
- local Load = LoadOrder.Unordered[i]
- HandleInit(Load[1],Load[2])
- end
- for i=1,#LoadOrder.Final do
- local Load = LoadOrder.Final[i]
- HandleInit(Load[1],Load[2])
- end
- end
- local suc,err = pcall(function() return getmetatable(Apollo) end) print("Apollo : Apollo Meta:",suc,err)
- return Apollo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement