Advertisement
dadragon84

MrJohnDowe Self Installer

Mar 3rd, 2014 (edited)
1,189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.96 KB | None | 0 0
  1. --3.5 by Mr John Dowe Apr-30-2023
  2. --based on the computercraft pastebin script.
  3.  
  4. local setLabel = os.getComputerID()
  5. if not setLabel then
  6.     shell.run("label set PC:"..tonumber(os.getComputerID()))
  7. end
  8.  
  9.  
  10. local code = {"WK68jh5d", "rJLuHR0g", "uzK5V1Kv", "YcDngWFp", "AE71CRnY", "BK6MCrZp", "tPKK0Vs3", "uwSCGam1", "bbz6S5Kw", "w4AGQE05", "h5n2gz7G", "ynVAgpaF", "d0hdE723", "f4rSnip8", "G6awvV8s", "FitDngkH", "meRmax76", "0JfKCUr1", "nna2VsZG", "uUPWBgPF", "EZqd0er1", "9GrQ8CT8","ZgGfdQkn","ZUiiQZHz","k2RpDss9","JxkPZ0FJ","ZLYJ9R4c","wC94sWss"}
  11. local file = {"TreeCutter", "TurtleFarm", "Marquee1", "Marquee2", "BigTreeFarm", "MinerInstall", "TreeFarm", "Monitor", "todolist", "WheatFarm", "Duties", "stairs", "TreeLogger", "RoomClear", "RoomMaker", "Quarry", "HouseBuilder", "TimberHouse", "TownHouse", "TouchScreen", "TreeFarmNoFuel", "inventorycontrol", "Server_Rules","Keycard","Schematica","Security_Code_Lock","File_Deleter","Bank_Installer"}
  12.  
  13. function getSettings(file)
  14.    local curSettings = file
  15.  
  16.     for i = 1, #curSettings do
  17.       textutils.pagedPrint( tonumber( i ) .. " : " .. curSettings[i] )
  18.     end
  19. end
  20.  
  21.  
  22. local input = nil
  23. local start = 0
  24. local stop = 0
  25.  
  26. function clear()
  27.   term.clear()
  28.   term.setCursorPos(1,1)
  29. end
  30.  
  31. if not http then
  32.     print( "Pastebin requires http API" )
  33.     print( "Set enableAPI_http to 1 in mod_ComputerCraft.cfg" )
  34.     return
  35. end
  36.  
  37. clear()
  38. print("Enter the corresponding number from the list or enter 0 to get all\n")
  39.  
  40. while input == nil do
  41.    --for i=1, #file do
  42.      -- write(i..":"..file[i].."   ")
  43.    --end
  44.     for i = 1, #file do
  45.       textutils.pagedPrint( tonumber( i ) .. " : " .. file[i] )
  46.     end
  47.    print("")
  48.    input = tonumber(read())
  49.    if input == 0 then
  50.       start = 1
  51.       stop = #code
  52.    else
  53.       start = input
  54.       stop = input
  55.    end
  56.    if input == nil then
  57.       clear()
  58.       print("Try again, but this time enter the NUMBER, or enter 0 for all, or hold ctrl+t to exit.\n")  
  59.    end
  60. end
  61.  
  62. for i=start, stop do
  63.     -- Download a file from pastebin.com
  64.     -- Determine file to download
  65.     local sCode = code[i]
  66.     local sFile = file[i]
  67.     local sPath = shell.resolve( sFile )
  68.     if fs.exists( sPath ) then
  69.                 --this will delete a script of the same name you are downloading to make room.
  70.                 --Good for updating scripts you have edited on pastebin.
  71.         fs.delete( sPath )
  72.     end
  73.    
  74.     -- GET the contents from pastebin
  75.     write( "Connecting to pastebin.com... " )
  76.     local response = http.get(
  77.         "http://pastebin.com/raw.php?i="..textutils.urlEncode( sCode )
  78.         )
  79.        
  80.     if response then
  81.         print( "Success." )
  82.        
  83.         local sResponse = response.readAll()
  84.         response.close()
  85.        
  86.         local file = fs.open( sPath, "w" )
  87.         file.write( sResponse )
  88.         file.close()
  89.        
  90.         term.clear()
  91.         term.setCursorPos(1,1)
  92.         print( "Downloaded as "..sFile )
  93.         sleep(1)
  94.        
  95.        
  96.     else
  97.         print( "Failed." )
  98.     end
  99.  
  100. print( "Thank you for using Mr John Dowe's programs, have fun!" )
  101. sleep(1)  
  102. shell.run( sFile )
  103. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement