Advertisement
dadragon84

Quarry Installer

Feb 18th, 2025 (edited)
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.25 KB | Source Code | 0 0
  1. --2.5 by JDowe Feb-18-2025
  2. --based on the computercraft pastebin script.
  3.  
  4. local code = {"9SkTv988", "GL8gn3ZS", "0b0zL6cx"}
  5. local file = {"QuarryRepeater", "QuarryReceiver", "turtleQuarry"}
  6.  
  7. function getSettings(file)
  8.    local curSettings = file
  9.  
  10.     for i = 1, #curSettings do
  11.       textutils.pagedPrint( tonumber( i ) .. " : " .. curSettings[i] )
  12.     end
  13. end
  14.  
  15.  
  16. local input = nil
  17. local start = 0
  18. local stop = 0
  19.  
  20. function clear()
  21.   term.clear()
  22.   term.setCursorPos(1,1)
  23. end
  24.  
  25. if not http then
  26.     print( "Pastebin requires http API" )
  27.     print( "Set enableAPI_http to 1 in mod_ComputerCraft.cfg" )
  28.     return
  29. end
  30.  
  31. clear()
  32. print("Enter the corresponding number from the list or enter 0 to get all\n")
  33.  
  34. while input == nil do
  35.    for i=1, #file do
  36.     write(i..":"..file[i].."   ")
  37.   end
  38.    -- for i = 1, #file do
  39.     --  textutils.pagedPrint( tonumber( i ) .. " : " .. file[i] )
  40.     --end
  41.    print("")
  42.    input = tonumber(read())
  43.    if input == 0 then
  44.       start = 1
  45.       stop = #code
  46.    else
  47.       start = input
  48.       stop = input
  49.    end
  50.    if input == nil then
  51.       clear()
  52.       print("Try again, but this time enter the NUMBER, or enter 0 for all, or hold ctrl+t to exit.\n")  
  53.    end
  54. end
  55.  
  56. for i=start, stop do
  57.     -- Download a file from pastebin.com
  58.     -- Determine file to download
  59.     local sCode = code[i]
  60.     local sFile = file[i]
  61.     local sPath = shell.resolve( sFile )
  62.     if fs.exists( sPath ) then
  63.                 --this will delete a script of the same name you are downloading to make room.
  64.                 --Good for updating scripts you have edited on pastebin.
  65.         fs.delete( sPath )
  66.     end
  67.    
  68.     -- GET the contents from pastebin
  69.     write( "Connecting to pastebin.com... " )
  70.     local response = http.get(
  71.         "http://pastebin.com/raw.php?i="..textutils.urlEncode( sCode )
  72.         )
  73.        
  74.     if response then
  75.         print( "Success." )
  76.        
  77.         local sResponse = response.readAll()
  78.         response.close()
  79.        
  80.         local file = fs.open( sPath, "w" )
  81.         file.write( sResponse )
  82.         file.close()
  83.        
  84.         term.clear()
  85.         term.setCursorPos(1,1)
  86.         print( "Downloaded as "..sFile )
  87.         sleep(1)
  88.        
  89.        
  90.     else
  91.         print( "Failed." )
  92.     end
  93.  
  94. print( "Thank you for using Mr John Dowe's programs, have fun!" )
  95. sleep(1)
  96. --shell.switchTab( shell.openTab(sFile) )    
  97. shell.run( sFile )
  98. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement