Advertisement
CdoubleOK

Speed Control (2 speed)

Sep 28th, 2024 (edited)
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.46 KB | Gaming | 0 0
  1. local modem = peripheral.find("modem")
  2. local monitor = peripheral.wrap("front")
  3.  
  4. monitor.clear()
  5. monitor.setCursorPos(1,1)
  6. monitor.setTextScale(0.5)
  7. term.clear()
  8. term.setCursorPos(1,1)
  9. print("Running...")
  10.  
  11.  
  12. local function shift(side, mode, bgc, tc)
  13.   rs.setOutput(side,true)
  14.   modem.transmit(2,3,mode)
  15.   monitor.setCursorPos(1,1)
  16.   monitor.clear()
  17.   monitor.setBackgroundColor(bgc)
  18.   monitor.setTextColor(tc)
  19.   monitor.setCursorPos(8, 4)
  20.   monitor.write("Automated Power Control")
  21.   monitor.setCursorPos(8, 5)
  22.   monitor.write("-=-=-=-=-=-=-=-=-=-=-=-")
  23.   monitor.setCursorPos(8, 6)
  24.   monitor.write(mode)
  25.   sleep(1)
  26.   rs.setOutput(side,false)
  27.   term.setCursorPos(1,3)
  28. end
  29.  
  30. while rs.getInput("front") == false
  31. do
  32.  
  33. if rs.getAnalogInput("top") >= 0 and rs.getAnalogInput("top") <= 3
  34. then
  35.   modem.transmit(2,3,"Offline")
  36.   monitor.setCursorPos(1,1)
  37.   monitor.clear()
  38.   monitor.setBackgroundColor(colors.red)
  39.   monitor.setTextColor(colors.white)
  40.   monitor.setCursorPos(8, 4)
  41.   monitor.write("Automated Power Control")
  42.   monitor.setCursorPos(8, 5)
  43.   monitor.write("-=-=-=-=-=-=-=-=-=-=-=-")
  44.   monitor.setCursorPos(8, 6)
  45.   monitor.write("Offline")
  46.   sleep(1)
  47.   term.setCursorPos(1,3)
  48.  
  49. elseif rs.getAnalogInput("top") >= 4 and rs.getAnalogInput("top") <= 14
  50. then
  51. shift ("left", "Low Power", colors.blue, colors.white)
  52.  
  53. elseif rs.getAnalogInput("top") == 15
  54. then
  55. shift ("right", "Full Power", colors.green, colors.white)
  56.  
  57. else
  58. return
  59. end
  60.  
  61. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement