Advertisement
HPWebcamAble

[CC][Installer] Advanced Redstone Control

Aug 15th, 2014
1,698
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.02 KB | None | 0 0
  1. --[[
  2. Coded by HPWebcamAble
  3. http://pastebin.com/u/HPWebcamAble
  4.  
  5. This installs 'Advanced Redstone Control 3.x' and all necesary components
  6. ]]
  7.  
  8. function clear() shell.run("clear") end
  9. function tc(...) term.setTextColor(...) end
  10.  
  11. --Rewritten part of the pastebin program
  12. function get(sCode,sFile)
  13.   local sPath = shell.resolve( sFile )
  14.   if fs.exists( sPath ) then
  15.     return false
  16.   end
  17.   local response = http.get("http://pastebin.com/raw.php?i="..textutils.urlEncode( sCode ))
  18.   if response then     
  19.     local sResponse = response.readAll()
  20.     response.close()       
  21.     local file = fs.open( sPath, "w" )
  22.     file.write( sResponse )
  23.     file.close()
  24.     return true    
  25.   else
  26.     return false
  27.   end  
  28. end
  29.  
  30. --Program--
  31.  
  32. if not http then
  33.   print("HTTP api is disabled on this world/Server")
  34.   return
  35. elseif not term.isColor() then
  36.   tc(colors.red)
  37.   print("This program requires an advanced computer")
  38.   return
  39. end
  40.  
  41. clear()
  42. tc(colors.yellow)
  43. term.write("Advanced Redstone Control 3.0")
  44. tc(colors.white)
  45. print(" is ready to be installed")
  46. tc(colors.blue)
  47. print("Press any key...")
  48.  
  49. os.pullEvent()
  50. os.pullEvent() --Captures both key and char events
  51.  
  52. --Start the install
  53. clear()
  54. tc(colors.white)
  55. print("Installing...")
  56.  
  57. --Add ARC directory
  58. print("Adding directory 'ARC'...")
  59. if fs.exists("ARC") then
  60.   if fs.isDir("ARC") then
  61.     tc(colors.orange)
  62.     print("Directory 'ARC' already exists on this computer")
  63.     tc(colors.red)
  64.     print("Install terminated. Remove or rename directory 'ARC'")
  65.     return
  66.   else
  67.     tc(colors.orange)
  68.     print("ARC exists as a program. Renaming...")
  69.     pRename = "ARC"
  70.     repeat
  71.       pRename = pRename.."~"
  72.     until not fs.exists(pRename)
  73.     tc(colors.white)
  74.     print("Renamed ARC to "..pRename)
  75.     shell.run("rename ARC "..pRename)
  76.   end
  77. end
  78. tc(colors.white)
  79. fs.makeDir("ARC")
  80. print("Successfully added directroy 'ARC'")
  81.  
  82. --Download Advanced Redstone Control from pastebin
  83. print("Downloading program 'Advanced Redstone Control' (ARC)...")
  84. if get("2ZPhx6ec","ARC/ARC") then
  85.   print("Success")
  86. else
  87.   tc(colors.red)
  88.   print("Could not download. Is pastebin working?")
  89.   return
  90. end
  91.  
  92. print("Downloading program 'Config Editor' (configeditor)...")
  93. if get("cKunvkD2","ARC/configeditor") then
  94.   print("Success")
  95. else
  96.   tc(colors.red)
  97.   print("Could not download. Is pastebin working?")
  98.   return
  99. end
  100.  
  101.  
  102. --Make Shortcut for Advanced Redstone Control
  103. print("Downloading shortcut (rc)...")
  104. if fs.exists("rc") then
  105.   tc(colors.orange)
  106.   print("rc program already exists. Renaming...")
  107.   pRename = "rc"
  108.   repeat
  109.     pRename = pRename.."~"
  110.   until not fs.exists(pRename)
  111.   tc(colors.white)
  112.   print("Renamed rc to "..pRename)
  113.   shell.run("rename rc "..pRename)
  114. end
  115. if get("y2pZUC3c","rc") then
  116.   print("Success")
  117. else
  118.   tc(colors.red)
  119.   print("Could not download. Is pastebin working?")
  120.   return
  121. end
  122.  
  123. tc(colors.lime)
  124. print("Advanced Redstone Control installed!")
  125. tc(colors.blue)
  126. print("Type 'rc' to run it, then follow the instruction to create the buttons")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement