Update netrequire.lua

This commit is contained in:
LDDestroier 2019-05-25 22:05:13 -04:00 committed by GitHub
parent abaeacb041
commit 9f730abab4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 5 deletions

View File

@ -13,12 +13,19 @@ local function netrequire(_name, alwaysDownload, ...)
local url = "https://github.com/LDDestroier/CC/raw/master/netrequire/" .. name local url = "https://github.com/LDDestroier/CC/raw/master/netrequire/" .. name
local net = http.get(url) local net = http.get(url)
if net then if net then
local contents = net.readAll() url = net.readLine()
net.close() net.close()
local file = fs.open(fs.combine(DL_path, name), "w") net = http.get(url)
file.write(contents) if net then
file.close() local contents = net.readAll()
return loadstring(contents)(...) net.close()
local file = fs.open(fs.combine(DL_path, name), "w")
file.write(contents)
file.close()
return loadstring(contents)(...)
else
error("Couldn't connect to '" .. url .. "'")
end
else else
error("Cannot find any such API '" .. name .. "'") error("Cannot find any such API '" .. name .. "'")
end end