Advertisement
Guest User

Telecommande portable

a guest
Nov 23rd, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.99 KB | None | 0 0
  1. w = peripheral.wrap("back")
  2. block = 0
  3. Sleep = 0.75
  4. largeur = 7
  5. closing = false
  6. off = false
  7. use = true
  8. term.setTextColor(colors.orange)
  9. term.setBackgroundColor(colors.lightGray)
  10. term.clear()
  11. sleep(1)
  12. term.setCursorPos(1,1)
  13. term.write("Ouverture en cours ...")
  14. while true do
  15. sleep(0.5)
  16. if off == false then
  17. if use == true then
  18. if block < largeur then
  19. block = block + 1
  20. -- On envoit la requete: ON
  21. w.transmit(2, 1, "ON")
  22. sleep(Sleep)
  23. -- Requete envoyee
  24. end
  25.  
  26. if block == largeur then
  27. off = true
  28. term.setCursorPos(1,2)
  29. term.write("Porte 1 ouverte.")
  30. sleep(5)
  31. end
  32. end
  33. end
  34.  
  35. if off == true then
  36. block = block - 1
  37. -- On envoit la requete: OFF
  38. w.transmit(2, 1, "OFF")
  39. sleep(Sleep)
  40. -- Requete envoyee
  41. if closing == false then
  42. closing = true
  43. term.setCursorPos(1,3)
  44. term.write("Fermeture de la porte 1.")
  45. end
  46. if block == 0 then
  47. off = false
  48. use = false
  49. term.setTextColor(colors.orange)
  50. term.setCursorPos(1,4)
  51. term.write("Porte 1 fermée")
  52. sleep(2)
  53. os.reboot()
  54. end
  55. end
  56. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement