Advertisement
JaMaNi133

ENGINE CONTROLS

Jan 19th, 2024 (edited)
825
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.28 KB | None | 0 0
  1. --pastebin get PYkQQmSx startup.lua
  2.  
  3. monitor = peripheral.wrap("monitor_6")
  4. speedControllersWater = {peripheral.wrap("Create_RotationSpeedController_1"),
  5.     peripheral.wrap("Create_RotationSpeedController_2"),
  6.     peripheral.wrap("Create_RotationSpeedController_0"),
  7.     peripheral.wrap("Create_RotationSpeedController_3"),
  8.     peripheral.wrap("Create_RotationSpeedController_4"),
  9.     peripheral.wrap("Create_RotationSpeedController_5")}
  10.  
  11. speedControllersLava = {peripheral.wrap("Create_RotationSpeedController_9"),
  12.     peripheral.wrap("Create_RotationSpeedController_10"),
  13.     peripheral.wrap("Create_RotationSpeedController_11"),
  14.     peripheral.wrap("Create_RotationSpeedController_12"),
  15.     peripheral.wrap("Create_RotationSpeedController_13"),
  16.     peripheral.wrap("Create_RotationSpeedController_14")}
  17.  
  18. clutchOutput = "top"
  19.  
  20.  
  21. lavaOff = 0.000000001
  22. lavaLow = 24
  23. lavaOn  = 128
  24.  
  25. waterOff = 0.000000001
  26. waterLow = 32
  27. waterOn  = 128
  28.  
  29. monitor.setBackgroundColor(colors.black)
  30. monitor.clear()
  31.  
  32. function loop()
  33.     --loop
  34.     monitor.setTextColor(colors.white)
  35.     monitor.setBackgroundColor(colors.lightGray)
  36.     monitor.setCursorPos(1,1)
  37.     monitor.write("Engine:       : 1 2 3 4 5 6")
  38.     monitor.setCursorPos(1,2)
  39.     monitor.setBackgroundColor(colors.lightBlue)
  40.     monitor.write("WaterOff      :  | | | | | ")
  41.     monitor.setCursorPos(1,3)
  42.     monitor.write("WaterLow      :  | | | | | ")
  43.     monitor.setCursorPos(1,4)
  44.     monitor.write("WaterHigh     :  | | | | | ")
  45.     monitor.setCursorPos(1,5)
  46.     monitor.setBackgroundColor(colors.orange)
  47.     monitor.write("LavaOff       :  | | | | | ")
  48.     monitor.setCursorPos(1,6)
  49.     monitor.write("LavaLow       :  | | | | | ")
  50.     monitor.setCursorPos(1,7)
  51.     monitor.write("LavaHigh      :  | | | | | ")
  52.     monitor.setCursorPos(1,8)
  53.     monitor.setBackgroundColor(colors.green)
  54.     monitor.write("EnableOutput               ")
  55.     monitor.setCursorPos(1,9)
  56.     monitor.setBackgroundColor(colors.red)
  57.     monitor.write("DisableOutput              ")
  58. end
  59.  
  60.  
  61.    
  62. function generalUpdate()
  63.     while true do
  64.         loop()
  65.         sleep(0.01)
  66.     end
  67. end
  68.  
  69. function respondMonitorTouched()
  70.     while true do
  71.         event, side, xPos, yPos = os.pullEvent("monitor_touch")
  72.         if xPos >= 17 and xPos <= 28 then
  73.             i_engine = math.floor((xPos-15)/2)
  74.             print(i_engine)
  75.             if yPos == 2 then
  76.                 speedControllersWater[i_engine].setTargetSpeed(waterOff)
  77.             end
  78.             if yPos == 3 then
  79.                 speedControllersWater[i_engine].setTargetSpeed(waterLow)
  80.             end
  81.             if yPos == 4 then
  82.                 speedControllersWater[i_engine].setTargetSpeed(waterOn)
  83.             end
  84.             if yPos == 5 then
  85.                 speedControllersLava[i_engine].setTargetSpeed(lavaOff)
  86.             end
  87.             if yPos == 6 then
  88.                 speedControllersLava[i_engine].setTargetSpeed(lavaLow)
  89.             end
  90.             if yPos == 7 then
  91.                 speedControllersLava[i_engine].setTargetSpeed(lavaOn)
  92.             end
  93.         end
  94.         if yPos == 8 then
  95.             redstone.setOutput(clutchOutput,true)
  96.         end
  97.         if yPos == 9 then
  98.             redstone.setOutput(clutchOutput,false)
  99.         end
  100.     end
  101. end
  102. sleep(15)
  103. parallel.waitForAny(respondMonitorTouched,generalUpdate)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement