This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
cdel's profile picture

github not downloading?

Started by cdel, 02 July 2014 - 01:58 PM
cdel #1
Posted 02 July 2014 - 03:58 PM
hey guys,
can someone help me out? when I run my program it doesn't save the GitHub file content.


function git(file, path)
  local remote = http.get("http://raw.github.com/connordelaneyy/CDEL-RPG/master/"..file)
  local code = remote.readAll()
  remote.close()
  file = fs.open(path, "w")
  file.write(code)
  file.close()
end

print("What would you like to install?")
print("[1] Server")
print("[2] Client")

input = read()
if input == "1" then
  git("server.lua", "server")
  print("Downloaded Server")
elseif input == "2" then
  git("client.lua", "client")
  print("Downloaded Client")
else
  error("Invalid Selection", 0)
end
theoriginalbit #2
Posted 02 July 2014 - 04:00 PM
if you're running ComputerCraft 1.6+ you need to add *github.com; to the http_whitelist in the ComputerCraft.cfg
cdel #3
Posted 02 July 2014 - 04:46 PM
I have, that's why I'm confused?
KingofGamesYami #4
Posted 02 July 2014 - 05:15 PM

file.write(code)  --#not with fs api
file.writeLine( code ) --#correct

Edit: OK then, guess fs does have write… What else could be wrong though?

Also, add a check to see if github responded

local remote = http.get("http://raw.github.com/connordelaneyy/CDEL-RPG/master/"..file)
if remote then 
 local code = remote.readAll()
 --#rest of code
else
 error( "http_failure" )
end
Edited on 03 July 2014 - 01:14 PM
theoriginalbit #5
Posted 03 July 2014 - 03:39 AM

file.write(code)  --#not with fs api
file.writeLine( code ) --#correct
ummm, yes there is a write on the file handle with the FS API, how else would you write data to the file without a new line? On a FS API file handle there is write, writeLine, flush, and close.