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 net = http.get(url)
if net then
local contents = net.readAll()
url = net.readLine()
net.close()
local file = fs.open(fs.combine(DL_path, name), "w")
file.write(contents)
file.close()
return loadstring(contents)(...)
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)(...)
else
error("Couldn't connect to '" .. url .. "'")
end
else
error("Cannot find any such API '" .. name .. "'")
end