Advertisement
Naxy73

apactat

May 26th, 2024 (edited)
626
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.58 KB | Gaming | 0 0
  1. --[[
  2. Coded by HPWebcamAble
  3. http://pastebin.com/u/HPWebcamAble
  4.  
  5. This installs 'Advanced Redstone Control 3.x' and all necessary components
  6.  
  7. **Multiplayer Note:** This script has been modified for multiplayer functionality.
  8.   - Server-side script approach:  Move download logic to server-side script.
  9.   - Resource pack approach:  Package files as a resource pack.
  10. ]]
  11.  
  12. function clear() shell.run("clear") end
  13. function tc(...) term.setTextColor(...) end
  14.  
  15. -- (Replace with server-side download logic or reference to resource pack location)
  16. function getProgram(programName, targetPath)
  17.   -- Download or access program from server-side location or resource pack
  18.   -- ... (implementation details based on chosen approach)
  19.  
  20.   -- Handle potential errors during download
  21.   local response = http.get("http://pastebin.com/raw/" .. textutils.urlEncode(programName))
  22.   if not response then
  23.     print("Error downloading " .. programName .. ": HTTP request failed")
  24.     return false
  25.   end
  26.  
  27.   local content = response.readAll()
  28.   response.close()
  29.  
  30.   if not content or content == "" then
  31.     print("Error downloading " .. programName .. ": Empty response")
  32.     return false
  33.   end
  34.  
  35.   local file = fs.open(targetPath, "w")
  36.   file.write(content)
  37.   file.close()
  38.  
  39.   return true
  40. end
  41.  
  42. --Program--
  43.  
  44. if not http then
  45.   print("HTTP api is disabled on this world/Server")
  46.   return
  47. elseif not term.isColor() then
  48.   tc(colors.red)
  49.   print("This program requires an advanced computer")
  50.   return
  51. end
  52.  
  53. clear()
  54. tc(colors.yellow)
  55. term.write("Advanced Redstone Control 3.0")
  56. tc(colors.white)
  57. print(" is ready to be installed")
  58. tc(colors.blue)
  59. print("Press any key...")
  60.  
  61. os.pullEvent("key")
  62. os.pullEvent("char")
  63.  
  64. clear()
  65. tc(colors.white)
  66. print("Installing...")
  67.  
  68. --Add ARC directory
  69. print("Adding directory 'ARC'...")
  70. if fs.exists("ARC") then
  71.   if fs.isDir("ARC") then
  72.     tc(colors.orange)
  73.     print("Directory 'ARC' already exists on this computer")
  74.     tc(colors.red)
  75.     print("Install terminated. Remove or rename directory 'ARC'")
  76.     return
  77.   else
  78.     tc(colors.orange)
  79.     print("ARC exists as a program. Renaming...")
  80.     local pRename = "ARC"
  81.     repeat
  82.       pRename = pRename .. "~"
  83.     until not fs.exists(pRename)
  84.     tc(colors.white)
  85.     print("Renamed ARC to " .. pRename)
  86.     shell.run("rename ARC " .. pRename)
  87.   end
  88. end
  89. tc(colors.white)
  90. fs.makeDir("ARC")
  91. print("Successfully added directory 'ARC'")
  92.  
  93. --Download Advanced Redstone Control (use getProgram function)
  94. print("Downloading program 'Advanced Redstone Control' (ARC)...")
  95. if getProgram("2ZPhx6ec", "ARC/ARC") then
  96.   print("Success")
  97. else
  98.   tc(colors.red)
  99.   print("Could not download. Is the resource pack installed?") -- Adjust message based on approach
  100.   return
  101. end
  102.  
  103. --Download Config Editor (use getProgram function)
  104. print("Downloading program 'Config Editor' (configeditor)...")
  105. if getProgram("cKunvkD2", "ARC/configeditor") then
  106.   print("Success")
  107. else
  108.   tc(colors.red)
  109.   print("Could not download. Is the resource pack installed?") -- Adjust message based on approach
  110.   return
  111. end
  112.  
  113. --Make Shortcut for Advanced Redstone Control
  114. print("Downloading shortcut (rc)...")
  115. if fs.exists("rc") then
  116.   tc(colors.orange)
  117.   print("rc program already exists. Renaming...")
  118.   local pRename = "rc"
  119.   repeat
  120.     pRename = pRename .. "~"
  121.   until not fs.exists(pRename)
  122.   tc(colors.white)
  123.   print("Renamed rc to " .. pRename)
  124.   shell.run("rename rc " .. pRename)
  125. end
  126. if getProgram("y2pZUC3c", "rc") then
  127.   print("Success")
  128. else
  129.   tc(colors.red)
  130.   print("Could not download. Is the resource pack installed?")
  131. end
  132.  
Tags: iDK
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement