Jump to content




github not downloading?


  • You cannot reply to this topic
4 replies to this topic

#1 cdel

  • Banned
  • 496 posts
  • LocationMelbourne, Australia

Posted 02 July 2014 - 02: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


#2 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 02 July 2014 - 03:00 PM

if you're running ComputerCraft 1.6+ you need to add *github.com; to the http_whitelist in the ComputerCraft.cfg

#3 cdel

  • Banned
  • 496 posts
  • LocationMelbourne, Australia

Posted 02 July 2014 - 03:46 PM

I have, that's why I'm confused?

#4 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 02 July 2014 - 04: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 by KingofGamesYami, 03 July 2014 - 02:14 PM.


#5 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 03 July 2014 - 02:39 AM

View PostKingofGamesYami, on 02 July 2014 - 04:15 PM, said:

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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users