Advertisement
craftyoyo

control touch

Oct 4th, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. os.loadAPI("button")
  2. m = peripheral.wrap("right")
  3. monitor = peripheral.wrap("left")
  4. m.clear()
  5.  
  6. function gotoln()
  7. local x, y = monitor.getCursorPos()
  8. if y1 == y then
  9. monitor.scroll(1)
  10. monitor.setCursorPos(1, y)
  11. else
  12. monitor.setCursorPos(1, y+1)
  13. end
  14. end
  15.  
  16. function button1() button.toggleButton("porte")
  17. monitor.write("porte ouvert !")
  18. redstone.setOutput("bottom", true)
  19. sleep(0.1)
  20. redstone.setOutput("bottom", false)
  21. gotoln()
  22. sleep(1)
  23. button.toggleButton("Poulailler")
  24. end
  25.  
  26. function button2() button.toggleButton("lumiere")
  27. monitor.write("lumiere allumer !")
  28. redstone.setOutput("back", true)
  29. sleep(0.1)
  30. redstone.setOutput("back", false)
  31. gotoln()
  32. sleep(1)
  33. button.toggleButton("Alarme")
  34. end
  35.  
  36. function button3() button.toggleButton("Champs")
  37. monitor.write("Champs changer !")
  38. redstone.setOutput("top", true)
  39. sleep(0.1)
  40. redstone.setOutput("top", false)
  41. gotoln()
  42. sleep(1)
  43. button.toggleButton("Champs")
  44. end
  45.  
  46.  
  47. function ecran()
  48. button.setTable("Poulailler",button1,8,25,3,3)
  49. button.setTable("lumiere",button2,8,25,6,6)
  50. button.setTable("Champs",button3,8,25,9,9)
  51. button.screen()
  52. end
  53.  
  54. function getClick()
  55. event,side,x,y = os.pullEvent("monitor_touch")
  56. button.checkxy(x,y)
  57. end
  58.  
  59. ecran()
  60.  
  61. while true do getClick() end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement