Advertisement
PlowmanPlow

ComputerCraft - Bootstrap Programs

Apr 29th, 2017
6,611
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.77 KB | None | 1 0
  1. --
  2. -- Getting started with PlowmanPlow's CC programs:
  3. --
  4. -- Copy and paste the line below in a CC computer command line:
  5. --
  6. -- pastebin run CrS25w1J
  7. --
  8.  
  9. local scripts = {}
  10.  
  11. scripts[1] = {id = "ejGGiwuT", name = "Base Status Monitor and Autocraft", file = "status.lua", startup = true}
  12. scripts[2] = {id = "cFSeSq42", name = "ME Network Status", file = "mestatus.lua", startup = true}
  13. scripts[3] = {id = "HW53E7TB", name = "BigReactor Monitor and Aux Control", file = "bigreactor.lua", startup = true}
  14. scripts[4] = {id = "GsrRcMZ5", name = "BigReactor Monitor", file = "bigreactor.lua", startup = true}
  15. scripts[5] = {id = "rKyaFNyZ", name = "Induction Matrix Monitor", file = "indmatrix.lua", startup = true}
  16. scripts[6] = {id = "zM6d7AAg", name = "Thermal Expansion Tank Monitor", file = "tetank.lua", startup = true}
  17. scripts[7] = {id = "RvbSNFBZ", name = "Draconic Reactor RF Storage", file = "draconicrf.lua", startup = true}
  18. scripts[8] = {id = "Lnuj6KAq", name = "Peripheral Method Enumeration", file = "methods.lua", startup = false}
  19. scripts[9] = {id = "jW8ka31Q", name = "Peripheral Method Documentation", file = "docs.lua", startup = false}
  20. scripts[10] = {id = "HWZsusLq", name = "Security System", file = "secsystem.lua", startup = true}
  21.  
  22. if not http then
  23.    printError("PlowmanPlow Bootstrapper requires HTTP API")
  24.    return
  25. end
  26.  
  27. local function get(script)
  28.    print("")
  29.    print("Downloading: " .. script.name)
  30.    local response = http.get("http://pastebin.com/raw.php?i=" .. textutils.urlEncode(script.id))
  31.    if response then
  32.       local contents = response.readAll()
  33.       response.close()
  34.       local file = fs.open(script.file, "w")
  35.       file.write(contents)
  36.       file.close()
  37.       print("Saved script: " .. script.file)
  38.       if ( script.startup == true ) then
  39.          local startup = 'shell.run("' .. script.file .. '")'
  40.          local file = fs.open("startup", "w")
  41.          file.write(startup)
  42.          file.close()
  43.          print("Created startup script")
  44.          print("Run 'startup' or reboot this computer")
  45.       end
  46.       print("")
  47.    else
  48.       printError("Pastebin retrieval failed.")
  49.    end
  50. end
  51.  
  52. print("")
  53. print("PlowmanPlow's CC Program Bootstrapper")
  54. print("")
  55. print("Select a program from the list below")
  56. print("Press 'q' to exit/cancel")
  57. print("")
  58. for index, script in pairs(scripts) do
  59.    print(index .. ". " .. script.name)
  60. end
  61.  
  62. while true do
  63.    local event, p1, p2, p3, p4 = os.pullEvent()
  64.    if event == "key" then
  65.       if p1 == keys.q then
  66.          print("")
  67.          return
  68.       else
  69.          local sId = tonumber(p1) - 1
  70.          if sId <= #scripts then
  71.             get(scripts[sId])
  72.             return
  73.          else
  74.             print("Please select a number from the list above")
  75.          end
  76.       end
  77.    end
  78. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement