Advertisement
Guest User

essentia

a guest
Jun 26th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.87 KB | None | 0 0
  1. mouseWidth = 0
  2. mouseHeight = 0
  3.  
  4. monitor = peripheral.wrap("right")
  5.  
  6. monitor.clear()
  7.  
  8.  
  9. monitor.setCursorPos(1,1)
  10.  
  11.  
  12. w,h=monitor.getSize()
  13.  
  14. monitor.setBackgroundColour((colours.lime))
  15. monitor.setCursorPos(2,2)
  16. monitor.write(" ON  ")
  17.  
  18. monitor.setBackgroundColor((colors.red))
  19. monitor.setCursorPos(2,4)
  20. monitor.write(" OFF ")
  21.  
  22. monitor.setBackgroundColour((colours.black))
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33. function checkClickPosition()
  34.   if mouseWidth > 1 and mouseWidth < 8 and mouseHeight == 2 then
  35.     rs.setOutput("right",true)
  36.   elseif mouseWidth > 1 and mouseWidth < 8 and mouseHeight == 4 then
  37.     rs.setOutput("right",false)
  38.   end
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45. repeat
  46.  
  47.   event,p1,p2,p3 = os.pullEvent()
  48.  
  49.    if event=="monitor_touch" then
  50.    
  51.      mouseWidth = p2
  52.      mouseHeight = p3
  53.      checkClickPosition()
  54.      
  55.    end
  56.    
  57.    
  58. until event=="char" and p1==("x")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement