Advertisement
HPWebcamAble

[CC][2.0][INSTALLER]Advanced Redstone Control

Aug 6th, 2014
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.79 KB | None | 0 0
  1. --[[
  2. Coded by HPWebcamAble
  3. http://pastebin.com/u/HPWebcamAble
  4.  
  5. This installs 'Advanced Redstone Control 2.0' and all necesary components
  6. ]]
  7.  
  8. --Functions--
  9. function clear() shell.run("clear") end
  10. function tc(...) term.setTextColor(...) end
  11.  
  12. function get(sCode,sFile) --This function is a modified portion of the Pastebin program
  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. if not http then
  32.   tc(colors.red)
  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 2.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.   end
  76. end
  77. tc(colors.white)
  78. fs.makeDir("ARC")
  79. print("Successfully added directroy 'ARC'")
  80.  
  81. --Download Advanced Redstone Control from pastebin
  82. print("Downloading program 'Advanced Redstone Control' (ARC)...")
  83. if get("7Y5sdrR4","ARC/ARC") then
  84.   print("Success")
  85. else
  86.   tc(colors.red)
  87.   print("Could not download. Is pastebin working?")
  88.   return
  89. end
  90.  
  91. --Make Shortcut for Advanced Redstone Control
  92. print("Creating shortcut...")
  93. if fs.exists("rc") then
  94.   tc(colors.orange)
  95.   print("Program (or directory) 'rc' already exists. Renaming...")
  96.   pRename = "rc"
  97.   repeat
  98.     pRename = pRename.."~"
  99.   until not fs.exists(pRename)
  100.   tc(colors.white)
  101.   print("Renamed ARC to "..pRename)
  102. end
  103. f = fs.open("rc","w")
  104. f.write([[shell.run("/ARC/ARC")]])
  105. f.close()
  106. print("Shortcut created")
  107.  
  108. tc(colors.lime)
  109. print("Advanced Redstone Control 2.0 installed!")
  110. tc(colors.blue)
  111. print("Type 'rc' to run it, then follow the instruction to create the buttons")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement