Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- MOD SETTINGS:
- ROOT = ROOT OF MAIN PROGRAM IN COMPUTER
- MODS = TABLE CONTAINING ALL MOD ROOTS, enter string containing root.
- ]]
- local root = "PUT PROGRAM ROOT HERE"
- local mods = {
- }
- --[[
- MOD INSTALLER CODE
- COMPATIBALE WITH MOST THINGS
- ]]
- local tAPIsLoading = {}
- local function loadMod(dir)
- if dir ~= nil then
- local _sPath = dir
- local sName = fs.getName( _sPath )
- local n = 1
- while tAPIsLoading[sName] == true and n < 300 do
- n = n + 1
- sleep(0)
- end
- if n < 300 then
- tAPIsLoading[sName] = true
- local tEnv = {}
- setmetatable( tEnv, { __index = _G } )
- local fnAPI, err = loadfile( _sPath )
- if fnAPI then
- setfenv( fnAPI, tEnv )
- fnAPI()
- else
- printError( err )
- tAPIsLoading[sName] = nil
- return nil
- end
- local tAPI = {}
- for k,v in pairs( tEnv ) do
- tAPI[k] = v
- end
- tAPIsLoading[sName] = nil
- return tAPI
- else
- return nil
- end
- else
- return nil
- end
- end
- if fs.exists(root) then
- local main = loadMod(root)
- main.startup()
- local lMods = {}
- for i=1,#mods do
- if fs.exists(mods[i]) then
- local md = loadMod(mods[i])
- md.run(main)
- lMods[#lMods + 1] = md
- end
- end
- main.run(lMods)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement