Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- EtatPorte = 0
- mouseWidth = 0
- mouseHeight = 0
- monitor = peripheral.wrap("top")
- monitor.clear()
- monitor.setCursorPos(1,1)
- w,h=monitor.getSize()
- print(w)
- print(h)
- monitor.setBackgroundColour((colours.red))
- monitor.setCursorPos(1,2)
- monitor.write(" Ouvrir ")
- monitor.setCursorPos(1,4)
- monitor.write(" Fermer ")
- monitor.setCursorPos(1,6)
- monitor.write(" test ")
- monitor.setBackgroundColour((colours.black))
- function checkClickPosition()
- if mouseWidth > 1 and mouseWidth < 8 and mouseHeight == 2 then
- EtatPorte = 1
- sleep(0.1)
- rednet.send(42, EtatPorte)
- elseif mouseWidth > 1 and mouseWidth < 8 and mouseHeight == 4 then
- EtatPorte = 0
- sleep(0.1)
- rednet.send(42, EtatPorte)
- elseif mouseWidth > 1 and mouseWidth < 8 and mouseHeight == 6 then
- EtatPorte = 0
- sleep(0.1)
- rednet.send(42, EtatPorte)
- end
- end
- repeat
- event,p1,p2,p3 = os.pullEvent()
- if event=="monitor_touch" then
- mouseWidth = p2 -- sets mouseWidth
- mouseHeight = p3 -- and mouseHeight
- checkClickPosition() -- this runs our function
- end
- until event=="char" and p1==("x")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement