Advertisement
Guest User

touchtest

a guest
Sep 19th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.78 KB | None | 0 0
  1. rednet.open("back")
  2.  
  3. mouseWidth = 0
  4. mouseHeigth = 0
  5.  
  6. term.clear()
  7.  
  8. monitor = peripheral.wrap("left")
  9.  
  10. monitor.setCursorPos(1,1)
  11. w,h=monitor.getSize()
  12.  
  13. monitor.setBackgroundColour((colours.lime))
  14.  
  15. monitor.setCursorPos(2,2)
  16. monitor.write("HOCH ")
  17. monitor.setCursorPos(2,4)
  18. monitor.write("RUFEN")
  19.  
  20. monitor.setBackgroundColour((colours.black))
  21.  
  22. function checkClickPosition()
  23.   if mouseWidth > 1 and mouseWidth < 8 and mouseHeight == 2 then
  24.   rednet.broadcast("8")
  25.  
  26.   elseif mouseWidth > 1 and mouseWidth < 8 and mouseHeight == 4 then
  27.   rednet.broadcast("2")
  28.   end
  29. end  
  30.  
  31.  
  32. repeat
  33.  
  34.   event,p1,p2,p3 = os.pullEvent()  
  35.  
  36.   if event=="monitor_touch" then
  37.  
  38.   mouseWidth = p2
  39.   mouseHeight = p3
  40.   checkClickPosition()
  41.  
  42.   end
  43.  
  44. until event=="char" and p1==("x")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement