Advertisement
iananderson

Untitled

Jun 16th, 2014
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. function checkClickPosition()
  41.   if mouseWidth == 10 and mouseHeight == 1 then
  42.     setpoint=1
  43.     print(setpoint)
  44.   elseif mouseWidth == 11 and mouseHeight == 1 then
  45.     setpoint=2
  46.     print(setpoint)
  47.   elseif mouseWidth == 12 and mouseHeight == 1 then
  48.     setpoint=3
  49.     print(setpoint)
  50.   elseif mouseWidth == 13 and mouseHeight == 1 then
  51.     setpoint=4
  52.     print(setpoint)
  53.   elseif mouseWidth == 14 and mouseHeight == 1 then
  54.     setpoint=5
  55.     print(setpoint)
  56.  
  57.   end -- ends the if loop
  58. end -- ends the function
  59.  
  60. while true do
  61.  event,p1,p2,p3 = os.pullEvent()
  62.  
  63.  while setpoint<1 then
  64.     if event=="monitor_touch" then
  65.        mouseWidth = p2 -- sets mouseWidth
  66.        mouseHeight = p3 -- and mouseHeight
  67.        checkClickPosition() -- this runs our function
  68.     end
  69.   end
  70.  
  71.   print("while end")
  72.  
  73.   x = p.getPressure()
  74.   print("pressure get")
  75.   y = setpoint
  76.   y1 = setpoint+0.45
  77.  
  78.   term.setCursorPos(1,3)
  79.   monitor.setCursorPos(1,3)
  80.  
  81.   term.write(x)
  82.   monitor.write(x)
  83.  
  84.   sleep(1)
  85.  
  86.   term.clearLine()
  87.   monitor.clearLine()
  88.  
  89.   if x < y then
  90.     rs.setOutput("right",true)
  91.     rs.setOutput("back",false)
  92.  
  93.   elseif x > y1 or x>4.9 then
  94.     rs.setOutput("back",true)
  95.   elseif x > y or x>4.9 then
  96.     rs.setOutput("right",false)
  97.   end
  98. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement