term.setBackgroundColor(colors.green)
term.clear()
term.setCursorPos(1,1)
term.setBackgroundColor(colors.blue)
term.clearLine()
term.setCursorPos(1,2)
term.clearLine()
term.setCursorPos(1,1)
write("Type Link to download from:")
term.setCursorPos(1,2)
local link = read()
local function get(link_)
if (http.checkURL(link_)) then
local data_ = http.get(link_)
local readall_ = data_.readAll()
return readall_
else
return "a"
end
end
if (get(link) == "a") then
term.setCursorPos(1,2)
term.clearLine()
write("Error: Invalid link!")
sleep(3)
dofile("/os/desktop")
else
if (fs.exists("download.tmp")) then
fs.delete("download.tmp")
end
local file = fs.open("download.tmp","w")
local dat = get(link)
file.write(dat)
file.close()
term.setCursorPos(1,1)
write(dat)
sleep(3)
dofile("/os/desktop")
end
Comments