Advertisement
ccgrffdy

qqds

Jan 14th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.45 KB | None | 0 0
  1. print("Bonjour")
  2. print("Mots de Passe :")
  3. MDP = ""
  4. if MDP == "" then
  5. rednet.open("back")
  6. local termWidth, termHeight = term.getSize()
  7. local selectedItem = 1
  8. local onMainMenu = true
  9. function GereMoteur()
  10.  term.clear()
  11.  term.setCursorPos(1,1)
  12. mainMenu = {
  13. [1] = { text = "Four Stone", handler = FourStat },
  14. [2] = { text = "Sable", handler = SableStat },
  15. }
  16. main()
  17.  sleep(1)
  18. end
  19.  
  20.  
  21. function SableStat()
  22. term.clear()
  23. term.setCursorPos(1,1)
  24. print("Four")
  25. mainMenu = {
  26. [1] = { text = "Allumer", handler = SableON },
  27. [2] = { text = "Arreter", handler = SableOFF },
  28. }
  29. main()
  30. sleep(1)
  31. end
  32. function SableON()
  33. term.clear()
  34. term.setCursorPos(1,1)
  35. print("Les pulverizer demare")
  36. rednet.send(70, 50)
  37. sleep(3)
  38. mainMenu = {
  39. [1] = { text = "Statut des Services", handler = GereMoteur },
  40. }
  41. main()
  42. end
  43. function SableOFF()
  44. term.clear()
  45. term.setCursorPos(1,1)
  46. print("Les pulverizer s'arretent")
  47. rednet.send(70, 57)
  48. sleep(3)
  49. mainMenu = {
  50. [1] = { text = "Statut des Services", handler = GereMoteur },
  51. }
  52. main()
  53. end
  54.  
  55.  
  56.  
  57. function FourStat()
  58. term.clear()
  59. term.setCursorPos(1,1)
  60. print("Four")
  61. mainMenu = {
  62. [1] = { text = "Allumer", handler = FourON },
  63. [2] = { text = "Arreter", handler = FourOFF },
  64. }
  65. main()
  66. sleep(1)
  67. end
  68. function FourON()
  69. term.clear()
  70. term.setCursorPos(1,1)
  71. print("Les fours s'allument")
  72. rednet.send(70, 10)
  73. sleep(3)
  74. mainMenu = {
  75. [1] = { text = "Statut des Services", handler = GereMoteur },
  76. }
  77. main()
  78. end
  79. function FourOFF()
  80. term.clear()
  81. term.setCursorPos(1,1)
  82. print("Les fours s'arretent")
  83. rednet.send(70, 17)
  84. sleep(3)
  85. mainMenu = {
  86. [1] = { text = "Statut des Services", handler = GereMoteur },
  87. }
  88. main()
  89. end
  90.  
  91.  
  92.  
  93. mainMenu = {
  94. [1] = { text = "Statut des Services", handler = GereMoteur },
  95. }
  96.  
  97. function printMenu( menu )
  98.  for i=1,#menu do
  99.   if i == selectedItem then
  100.    print("-> "..menu[i].text)
  101.   else
  102.    print("   "..menu[i].text)
  103.   end
  104.  end
  105. end
  106. function onKeyPressed( key, menu )
  107.  if key == keys.enter then
  108.   onItemSelected(menu)
  109.  elseif key == keys.up then
  110.   if selectedItem > 1 then
  111.    selectedItem = selectedItem - 1
  112.   end
  113.  elseif key == keys.down then
  114.   if selectedItem < #menu then
  115.    selectedItem = selectedItem + 1
  116.   end
  117.  end
  118. end
  119.  
  120. function onItemSelected( menu )
  121.  menu[selectedItem].handler()
  122. end
  123.  
  124. function main()
  125.  while onMainMenu do
  126. term.clear()
  127. term.setCursorPos(1,1)
  128.    printMenu(mainMenu)
  129.   event, key = os.pullEvent("key")
  130.   onKeyPressed(key,mainMenu)
  131.  end
  132. end
  133.  
  134.  
  135. main()
  136. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement