Advertisement
HPWebcamAble

[CC][Installer] Redstone Engine

Sep 28th, 2014
520
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.40 KB | None | 0 0
  1. --[[
  2. Coded by HPWebcamAble
  3.  
  4. This program installs my Redstone Engine program and all of its components
  5. After you have run this once, you shouldn't need this again (if its successful)
  6. ]]
  7.  
  8. function get(sCode,sFile) --This function is a modified portion of the Pastebin program
  9.   local sPath = shell.resolve( sFile )
  10.   if fs.exists( sPath ) then
  11.     return false
  12.   end
  13.   local response = http.get("http://pastebin.com/raw.php?i="..textutils.urlEncode( sCode ))
  14.   if response then              
  15.     local sResponse = response.readAll()
  16.     response.close()            
  17.     local file = fs.open( sPath, "w" )
  18.     file.write( sResponse )
  19.     file.close()
  20.     return true          
  21.   else
  22.     return false
  23.   end    
  24. end
  25.  
  26.  
  27. if not term.isColor() then
  28.   print("This program is designed for advanced computers only")
  29.   return
  30. elseif not http then
  31.   print("The Http api isn't enabled. Its required to download things from pastebin.")
  32.   print("It can be enabled in the Computer Craft Config file.")
  33.   return
  34. end
  35.  
  36. print("The following files will be deleted if they exist:")
  37. print("Directory: RED")
  38. print("Program: RE")
  39. print(" ")
  40. print("Make sure existing programs don't have these names.")
  41. print("Press 'Tab' to cancel or 'Enter' to continue")
  42.  
  43. local continue = false
  44. while true do
  45.   event,key = os.pullEvent("key")
  46.   if key == keys.enter then
  47.     continue = true
  48.     break
  49.   elseif key == keys.tab then
  50.     term.setTextColor(colors.red)
  51.     print("Canceled")
  52.     break
  53.   end
  54. end
  55.  
  56. if not continue then return end
  57.  
  58. if fs.exists("RED") then
  59.   shell.run("delete RED")
  60. end
  61.  
  62. if fs.exists("RE") then
  63.   shell.run("delete RE")
  64. end
  65.  
  66.  
  67. local problem = false
  68. shell.run("mkdir RED")
  69. shell.run("mkdir /RED/configs")
  70. if not get("t8qyvmSH","RE") then
  71.   print("Could not download 'RE' shortcut program")
  72.   problem = true
  73. else
  74.   print("Downloaded 'RE' shortcut program")
  75. end
  76.  
  77. if not get("uTJEepZQ","/RED/ConfigEditor") then
  78.   print("Could not download 'ConfigEditor' program")
  79.   problem = true
  80. else
  81.   print("Downloaded 'ConfigEditor' program")
  82. end
  83.  
  84. if not get("PT5jLy4i","/RED/RE") then
  85.   print("Could not download 'RE' program")
  86.   problem = true
  87. else
  88.   print("Downloaded 'RE' program")
  89. end
  90.  
  91. if problem then
  92.   term.setTextColor(colors.red)
  93.   print("Something when wrong. Program was not installed")
  94. else
  95.   term.setTextColor(colors.lime)
  96.   print("Program installed! Type 'RE' to run")
  97. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement