Advertisement
iananderson

Untitled

Jun 17th, 2014
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.58 KB | None | 0 0
  1. p = peripheral.wrap("back")
  2. local monitor = peripheral.wrap("top")
  3.  
  4. term.clear()
  5. monitor.clear()
  6. monitor.setTextScale(0.5)
  7.  
  8. term.setCursorPos(1,1)
  9. monitor.setCursorPos(1,1)
  10.  
  11. write("Enter Setpoint: ")
  12. monitor.write("Enter Setpoint: ")
  13.  
  14. input = tonumber(read())
  15.  
  16. term.setCursorPos(1,5)
  17.  
  18. term.write("Press 'X' to cancel")
  19. monitor.write("Press 'X' to cancel")
  20.  
  21. if input < 5 or input > 0 then
  22.   term.clear()
  23.   monitor.clear()
  24.  
  25.   term.setCursorPos(1,1)
  26.   monitor.setCursorPos(1,1)
  27.  
  28.   term.write("Setpoint:")
  29.   monitor.write("Setpoint:")
  30.  
  31.   term.write(input)
  32.   monitor.write(input)
  33.  
  34.   term.setCursorPos(1,2)
  35.   monitor.setCursorPos(1,2)
  36.  
  37.   term.write("Pressure:")
  38.   monitor.write("Pressure:")
  39. else
  40.   term.write("Setpoint must be between 0 and 5")
  41.   monitor.write("Setpoint must be between 0 and 5")
  42.   end
  43.  
  44. while true do
  45.   x = p.getPressure()
  46.   y = input
  47.   y1 = input+0.45
  48.  
  49.   term.setCursorPos(1,3)
  50.   monitor.setCursorPos(1,3)
  51.  
  52.   term.write(x)
  53.   monitor.write(x)
  54.  
  55.   sleep(1)
  56.  
  57.   term.clearLine()
  58.   monitor.clearLine()
  59.  
  60.   if x < y then
  61.     rs.setOutput("right",true)
  62.     rs.setOutput("back",false)
  63.  
  64.   elseif x > y1 or x>4.9 then
  65.     rs.setOutput("back",true)
  66.   elseif x > y or x>4.9 then
  67.     rs.setOutput("right",false)
  68.     end
  69.    
  70.     os.queueEvent("event_marker")
  71.   local breakOut = false
  72.   while true do
  73.     event, key = os.pullEvent()
  74.     if key == keys.x then --add any other events that should break the loop if necessary
  75.       breakOut = true
  76.     elseif key == "event_marker" then
  77.       break
  78.     end
  79.   end
  80.   if breakOut then break end
  81. end
  82. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement