mirror of
https://github.com/LDDestroier/CC/
synced 2025-01-07 07:50:26 +00:00
Added support for os.loadAPI()
This commit is contained in:
parent
19d568af52
commit
d8a063bd4e
@ -9,28 +9,42 @@ local function netrequire(_name, alwaysDownload, ...)
|
||||
name = _name
|
||||
end
|
||||
|
||||
if (not fs.exists(fs.combine(DL_path, name))) or alwaysDownload then
|
||||
if fs.exists(fs.combine(DL_path .. "/require", name)) and not alwaysDownload then
|
||||
return loadfile(fs.combine(DL_path .. "/require", name))(...)
|
||||
|
||||
elseif fs.exists(fs.combine(DL_path .. "/loadAPI", name)) and not alwaysDownload then
|
||||
os.loadAPI(fs.combine(DL_path .. "/loadAPI", name))
|
||||
return _ENV[fs.getName(name)]
|
||||
|
||||
else
|
||||
local url = "https://github.com/LDDestroier/CC/raw/master/netrequire/" .. name
|
||||
local net = http.get(url)
|
||||
if net then
|
||||
url = net.readLine()
|
||||
local useLoadAPI = net.readLine():sub(1, 4) == "true"
|
||||
net.close()
|
||||
net = http.get(url)
|
||||
if net then
|
||||
local contents = net.readAll()
|
||||
net.close()
|
||||
local file = fs.open(fs.combine(DL_path, name), "w")
|
||||
file.write(contents)
|
||||
file.close()
|
||||
return loadstring(contents)(...)
|
||||
if useLoadAPI then
|
||||
local file = fs.open(fs.combine(DL_path .. "/loadAPI", name), "w")
|
||||
file.write(contents)
|
||||
file.close()
|
||||
os.loadAPI(fs.combine(DL_path .. "/loadAPI", name))
|
||||
return _ENV[fs.getName(name)]
|
||||
else
|
||||
local file = fs.open(fs.combine(DL_path .. "/require", name), "w")
|
||||
file.write(contents)
|
||||
file.close()
|
||||
return loadstring(contents)(...)
|
||||
end
|
||||
else
|
||||
error("Couldn't connect to '" .. url .. "'")
|
||||
end
|
||||
else
|
||||
error("Cannot find any such API '" .. name .. "'")
|
||||
end
|
||||
else
|
||||
return loadfile(fs.combine(DL_path, name))(...)
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user