Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tAPIsLoading = {}
- function newClass(path)
- local _sPath = path
- 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
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement