GraySloth

ComputerCraft: 'graysloth' gets all of my scrips at once.

Feb 6th, 2013
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.20 KB | None | 0 0
  1. --v2.4 by GraySloth 2013-Mar-05
  2. --here is a old video demonstration of my scripts, it is almost good. http://youtu.be/9vhl7dSENs8
  3. --based on the computercraft pastebin script.
  4. --you can use it for your scripts just replace the codes below and their corresponding names
  5. local code = {"WK68jh5d", "Hed6CHcw", "9TUMx5PF", "WZAL4m7k", "Wc0pe95Z", "yigYBdad", "UkzR2J5T", "RyCpNStV", "M1j5n7ZY", "uq08abej", "cDfcamyP", "VYbhTFqm"}
  6. local file = {"strip", "stairs", "shaft", "fuel", "fell", "monStartup", "clock", "feed", "fill", "thaum", "lamp", "xp"}
  7.  
  8. local input = nil
  9. local start = 0
  10. local stop = 0
  11.  
  12. function clear()
  13.   term.clear()
  14.   term.setCursorPos(1,1)
  15. end
  16.  
  17. if not http then
  18.     print( "Pastebin requires http API" )
  19.     print( "Set enableAPI_http to 1 in mod_ComputerCraft.cfg" )
  20.     return
  21. end
  22.  
  23. clear()
  24. print("Enter the corresponding number from the list or enter 0 to get all\n")
  25.  
  26. while input == nil do
  27.    for i=1, #file do
  28.       write(i..":"..file[i].."   ")
  29.    end
  30.    print("")
  31.    input = tonumber(read())
  32.    if input == 0 then
  33.       start = 1
  34.       stop = #code
  35.    else
  36.       start = input
  37.       stop = input
  38.    end
  39.    if input == nil then
  40.       clear()
  41.       print("Try again, but this time enter the NUMBER, or enter 0 for all, or hold ctrl+t to exit.\n")  
  42.    end
  43. end
  44.  
  45. for i=start, stop do
  46.     -- Download a file from pastebin.com
  47.     -- Determine file to download
  48.     local sCode = code[i]
  49.     local sFile = file[i]
  50.     local sPath = shell.resolve( sFile )
  51.     if fs.exists( sPath ) then
  52.                 --this will delete a script of the same name you are downloading to make room.
  53.                 --Good for updating scripts you have edited on pastebin.
  54.         fs.delete( sPath )
  55.     end
  56.    
  57.     -- GET the contents from pastebin
  58.     write( "Connecting to pastebin.com... " )
  59.     local response = http.get(
  60.         "http://pastebin.com/raw.php?i="..textutils.urlEncode( sCode )
  61.         )
  62.        
  63.     if response then
  64.         print( "Success." )
  65.        
  66.         local sResponse = response.readAll()
  67.         response.close()
  68.        
  69.         local file = fs.open( sPath, "w" )
  70.         file.write( sResponse )
  71.         file.close()
  72.        
  73.         print( "Downloaded as "..sFile )
  74.        
  75.     else
  76.         print( "Failed." )
  77.     end
  78. end
  79. print( "Thank you for using GraySloth's programs, have fun!" )
Advertisement
Add Comment
Please, Sign In to add comment