Posted 29 March 2013 - 02:56 PM
As title a small modification to os.loadAPI to allow user specified api name. Only a small modification is needed in os.loadAPI and it would be back words compatible with previous functions.
Spoiler
function os.loadAPI( _sPath , _sName)
local sName = _sName or fs.getName( _sPath )
if tAPIsLoading[sName] == true then
printError( "API "..sName.." is already being loaded" )
return false
end
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 false
end
local tAPI = {}
for k,v in pairs( tEnv ) do
tAPI[k] = v
end
_G[sName] = tAPI
tAPIsLoading[sName] = nil
return true
end