Advertisement
ash4567893

open/close

Jul 14th, 2014
167
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. monitor = peripheral.wrap("top")
  4. monitor.clear()
  5. monitor.setCursorPos(1,1)
  6. w,h=monitor.getSize()
  7. print(w)
  8. print(h)
  9. -- this can be any color in the computercraft color api
  10. monitor.setBackgroundColour((colors.red))
  11. monitor.setCursorPos(2,2)
  12. monitor.write("open ")
  13. monitor.setCursorPos(2,4)
  14. monitor.write("close")
  15. --this can be any color in the computercraft color api
  16. monitor.setBackgroundColour((colors.black))
  17. function checkClickPosition()
  18.  if mouseWidth > 1
  19.  and mouseWidth < 8
  20.  and mouseHeight == 2 then
  21.   rs.setOutput("right",true)
  22.  elseif mouseWidth > 1
  23.  and mouseWidth < 8
  24.  and MouseHeight == 4 then
  25.   rs.setOutput("right",false)
  26.  end
  27. end
  28. repeat
  29.  event,p1,p2,p3 = os.pullEvent()
  30.   if event=="monitor_touch" then
  31.    mouseWidth = p2
  32.    mouseHeight = P3
  33.    checkClickPosition()
  34.   end
  35. until event=="char"
  36. and p1==("x")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement