Advertisement
iananderson

Untitled

Jun 17th, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.62 KB | None | 0 0
  1. mouseWidth = 0
  2. mouseHeight = 0
  3.  
  4. p = peripheral.wrap("back")
  5. monitor = peripheral.wrap("top")
  6.  
  7. monitor.clear()
  8. monitor.setTextScale(0.5)
  9.  
  10. monitor.setCursorPos(1,1)
  11. monitor.write("Setpoint:")
  12. monitor.setCursorPos(1,2)
  13. monitor.write("Pressure:")
  14. monitor.setCursorPos(1,1)
  15.  
  16. w,h=monitor.getSize()
  17.  
  18. print(w)
  19. print(h)
  20.  
  21. monitor.setBackgroundColour((colours.lime))
  22.  
  23. monitor.setCursorPos(10,1)
  24. monitor.write("1")
  25.  
  26. monitor.setCursorPos(11,1)
  27. monitor.write("2")
  28.  
  29. monitor.setCursorPos(12,1)
  30. monitor.write("3")
  31.  
  32. monitor.setCursorPos(13,1)
  33. monitor.write("4")
  34.  
  35. monitor.setCursorPos(14,1)
  36. monitor.write("5")
  37.  
  38. monitor.setBackgroundColour((colours.black))
  39.  
  40. while true do
  41.  event,side,mouseWidth,mouseHeight = os.pullEvent(monitor_touch)
  42.  
  43.   if mouseWidth == 10 and mouseHeight == 1 then
  44.     setpoint=1
  45.     print(setpoint)
  46.   end
  47.   if mouseWidth == 11 and mouseHeight == 1 then
  48.     setpoint=2
  49.     print(setpoint)
  50.   end
  51.   if mouseWidth == 12 and mouseHeight == 1 then
  52.     setpoint=3
  53.     print(setpoint)
  54.   end
  55.   if mouseWidth == 13 and mouseHeight == 1 then
  56.     setpoint=4
  57.     print(setpoint)
  58.   end
  59.   if mouseWidth == 14 and mouseHeight == 1 then
  60.     setpoint=5
  61.     print(setpoint)
  62.   end
  63.  
  64.   x = p.getPressure()
  65.   y = setpoint
  66.   y1 = y+0.45
  67.  
  68.   term.setCursorPos(1,3)
  69.   monitor.setCursorPos(1,3)
  70.  
  71.   term.write(x)
  72.   monitor.write(x)
  73.  
  74.   sleep(1)
  75.  
  76.   term.clearLine()
  77.   monitor.clearLine()
  78.  
  79.   if x < y then
  80.     rs.setOutput("right",true)
  81.     rs.setOutput("back",false)
  82.   elseif x > y1 or x>4.9 then
  83.     rs.setOutput("back",true)
  84.   elseif x > y or x>4.9 then
  85.     rs.setOutput("right",false)
  86.   end
  87. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement