Advertisement
tman1123

ElevatorDisplayInstall.lua

Apr 1st, 2024 (edited)
852
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Clear the screen at the beginning
  2. term.clear()
  3. term.setCursorPos(1,1)
  4.  
  5. -- Centered Menu Title
  6. local w, h = term.getSize()
  7. local title = "Elevator Display Control Download"
  8. local menuLine1 = "Please input 1 for controller and 2 for receiver"
  9. term.setCursorPos((w - #title) / 2, 2)
  10. print(title)
  11. term.setCursorPos((w - #menuLine1) / 2, 4)
  12. print(menuLine1)
  13.  
  14. -- Function to get centered input
  15. function centeredInput(line)
  16.     term.setCursorPos((w - #menuLine1) / 2, line)
  17.     return read()
  18. end
  19.  
  20. -- Get user choice and validate input
  21. local choice = centeredInput(6)
  22. if choice ~= "1" and choice ~= "2" then
  23.     print("Invalid choice. Please restart and input 1 or 2.")
  24.     return
  25. end
  26.  
  27. -- Functions to download and setup for controller and receiver
  28. function setupController()
  29.     shell.run("pastebin get bW4979ft controller")
  30.     shell.run("pastebin get Wa7cyS89 setup")
  31.     -- Create startup file
  32.     local file = fs.open("startup", "w")
  33.     file.writeLine("shell.run('controller')")
  34.     file.close()
  35.     -- Open controller setup program
  36.     shell.run("setup")
  37. end
  38.  
  39. function setupReceiver()
  40.     shell.run("pastebin get CydZ2XTT receiver")
  41.     shell.run("pastebin get 1xSfg2et setup")
  42.     -- Create startup file
  43.     local file = fs.open("startup", "w")
  44.     file.writeLine("shell.run('receiver')")
  45.     file.close()
  46.     -- Open receiver setup program
  47.     shell.run("setup")
  48. end
  49.  
  50. -- Execute based on choice
  51. if choice == "1" then
  52.     setupController()
  53. elseif choice == "2" then
  54.     setupReceiver()
  55. end
  56.  
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement