Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. EtatPorte = 0
  2.  
  3. mouseWidth = 0
  4. mouseHeight = 0
  5.  
  6. monitor = peripheral.wrap("top")
  7.  
  8. monitor.clear()
  9.  
  10. monitor.setCursorPos(1,1)
  11.  
  12. w,h=monitor.getSize()
  13.  
  14. print(w)
  15. print(h)
  16.  
  17. monitor.setBackgroundColour((colours.red))
  18.  
  19. monitor.setCursorPos(1,2)
  20.  
  21. monitor.write(" Ouvrir ")
  22.  
  23. monitor.setCursorPos(1,4)
  24.  
  25. monitor.write(" Fermer ")
  26.  
  27. monitor.setCursorPos(1,6)
  28.  
  29. monitor.write(" test ")
  30.  
  31. monitor.setBackgroundColour((colours.black))
  32.  
  33. function checkClickPosition()
  34.  
  35. if mouseWidth > 1 and mouseWidth < 8 and mouseHeight == 2 then
  36. EtatPorte = 1
  37. sleep(0.1)
  38. rednet.send(42, EtatPorte)
  39.  
  40. elseif mouseWidth > 1 and mouseWidth < 8 and mouseHeight == 4 then
  41. EtatPorte = 0
  42. sleep(0.1)
  43. rednet.send(42, EtatPorte)
  44.  
  45. elseif mouseWidth > 1 and mouseWidth < 8 and mouseHeight == 6 then
  46. EtatPorte = 0
  47. sleep(0.1)
  48. rednet.send(42, EtatPorte)
  49. end
  50.  
  51. end
  52.  
  53. repeat
  54.  
  55. event,p1,p2,p3 = os.pullEvent()
  56.  
  57. if event=="monitor_touch" then
  58.  
  59. mouseWidth = p2 -- sets mouseWidth
  60. mouseHeight = p3 -- and mouseHeight
  61. checkClickPosition() -- this runs our function
  62.  
  63. end
  64.  
  65.  
  66. until event=="char" and p1==("x")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement