Advertisement
guitarplayer616

Github

Nov 27th, 2016
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.14 KB | None | 0 0
  1. git = {}
  2. sArgs = ...
  3.  
  4. Branch = "patch2"
  5. if sArgs then
  6.     Branch = sArgs
  7. end
  8.  
  9. function createFile(filename,string)
  10.     local h = fs.open(filename,"w")
  11.     h.write(string)
  12.     h.close()
  13. end
  14.  
  15. function git.get(address,filename)
  16.     write("Connecting to github.com... ")
  17.     local response = http.get(address)
  18.     if response then
  19.         print("")
  20.         print( "Downloaded as "..filename )
  21.     else
  22.         print("")
  23.         error("No response recieved : "..address)
  24.     end
  25.     createFile(filename,response.readAll())
  26. end
  27.  
  28. function git.run(address,...)
  29.     sCode = http.get(address).readAll()
  30.     if sCode then
  31.         local func, err = loadstring(sCode)
  32.         if not func then
  33.             printError( err )
  34.             return
  35.         end
  36.         setfenv(func, getfenv())
  37.         local success, msg = pcall(func, unpack(...))
  38.         if not success then
  39.             printError( msg )
  40.         end
  41.     end
  42. end
  43.  
  44. --git.run("https://raw.githubusercontent.com/GuitarMusashi616/SchematicTurtle/Swarm/setup.lua",{"update"})
  45. --print("Branch = "..Branch)
  46. git.get("https://raw.githubusercontent.com/GuitarMusashi616/SchematicTurtle/"..Branch.."/setup.lua","setup")
  47. --git.run(goAddress,{"rt","4","fd","2})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement