Advertisement
Guest User

Untitled

a guest
Mar 18th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.71 KB | None | 0 0
  1. local tChoices = {}
  2. tChoices[0] = 'Squelette'
  3. tChoices[1] = 'Golem de fer'
  4. tChoices[2] = 'Blaze'
  5. tChoices[3] = 'Spider'
  6. tChoices[0] = 'Pigmen'
  7. tChoices[0] = 'Enderman'
  8. tChoices[0] = 'Zombie'
  9. tChoices[0] = 'Mouton'
  10.  
  11.  
  12. table.insert(tChoices, 'Shutdown')
  13. local nTermX, nTermY = term.getSize()
  14. local sSeperator = ("-"):rep(nTermX)
  15.  
  16. local tActions = {}
  17.  
  18.  
  19.  
  20. tActions[0] = function()
  21. term.clear()
  22. term.setCursorPos(1, 1)
  23. print(sSeperator)
  24. print("| Terminal Password |")
  25. print(sSeperator)
  26. print("Attention")
  27. term.setCursorPos(1, nTermY) -- Move the cursor to the bottom
  28. write(" [appuyez sur entrer]")
  29. read()
  30. end
  31.  
  32. tActions[1] = function()
  33. term.clear()
  34. term.setCursorPos(1, 1)
  35. print(sSeperator)
  36. print("| Terminal Password |")
  37. print(sSeperator)
  38. print("Attention")
  39. term.setCursorPos(1, nTermY) -- Move the cursor to the bottom
  40. write(" [appuyez sur entrer]")
  41. read()
  42. end
  43.  
  44. tActions[2] = function()
  45. term.clear()
  46. term.setCursorPos(1, 1)
  47. print(sSeperator)
  48. print("| Terminal Password |")
  49. print(sSeperator)
  50. print("Attention")
  51. term.setCursorPos(1, nTermY) -- Move the cursor to the bottom
  52. write(" [appuyez sur entrer]")
  53. read()
  54. end
  55.  
  56. tActions[3] = function()
  57. term.clear()
  58. term.setCursorPos(1, 1)
  59. print(sSeperator)
  60. print("| Terminal Password |")
  61. print(sSeperator)
  62. print("Attention")
  63. term.setCursorPos(1, nTermY) -- Move the cursor to the bottom
  64. write(" [appuyez sur entrer]")
  65. read()
  66.  
  67. end
  68.  
  69. tActions[4] = function()
  70. term.clear()
  71. term.setCursorPos(1, 1)
  72. print(sSeperator)
  73. print("| Terminal Password |")
  74. print(sSeperator)
  75. print("Attention")
  76. term.setCursorPos(1, nTermY) -- Move the cursor to the bottom
  77. write(" [appuyez sur entrer]")
  78. read()
  79.  
  80. end
  81.  
  82. tActions[5] = function()
  83. term.clear()
  84. term.setCursorPos(1, 1)
  85. print(sSeperator)
  86. print("| Terminal Password |")
  87. print(sSeperator)
  88. print("Attention")
  89. term.setCursorPos(1, nTermY) -- Move the cursor to the bottom
  90. write(" [appuyez sur entrer]")
  91. read()
  92.  
  93. end
  94.  
  95. tActions[6] = function()
  96. term.clear()
  97. term.setCursorPos(1, 1)
  98. print(sSeperator)
  99. print("| Terminal Password |")
  100. print(sSeperator)
  101. print("Attention")
  102. term.setCursorPos(1, nTermY) -- Move the cursor to the bottom
  103. write(" [appuyez sur entrer]")
  104. read()
  105.  
  106. end
  107.  
  108. tActions[7] = function()
  109. term.clear()
  110. term.setCursorPos(1, 1)
  111. print(sSeperator)
  112. print("| Terminal Password |")
  113. print(sSeperator)
  114. print("Attention")
  115. term.setCursorPos(1, nTermY) -- Move the cursor to the bottom
  116. write(" [appuyez sur entrer]")
  117. read()
  118.  
  119. end
  120.  
  121. tActions[8] = function()
  122. term.clear()
  123. term.setCursorPos(1, 1)
  124. print(sSeperator)
  125. print("| Terminal Password |")
  126. print(sSeperator)
  127. print("Attention")
  128. term.setCursorPos(1, nTermY) -- Move the cursor to the bottom
  129. write(" [appuyez sur entrer]")
  130. read()
  131.  
  132. end
  133.  
  134. table.insert(tActions, os.shutdown) -- Insert the shutdown function at the end to compliment the "Shutdown" menu item :)
  135.  
  136. -- Do the above for the remaining
  137.  
  138. local nSelection = 0 -- The current selection defaults at 0
  139. repeat
  140. term.setCursorPos(1, 1)
  141. term.clear()
  142. print(sSeperator)
  143. print("| FantomQc pour vous servir! |")
  144. print(sSeperator)
  145.  
  146. for nLine = 0, #tChoices do -- Iterate through the possible potions, and print them, marking the chosen one
  147. local sLine = " "
  148. if nSelection == nLine then
  149. sLine = ">"
  150. end
  151. local sLineNum = tostring(nLine)
  152. if #sLineNum < 2 then
  153. sLineNum = "0" .. sLineNum -- Prepend a 0 if it's too short
  154. end
  155. sLine = sLine .. "[" .. sLineNum .. "]" .. " " .. tChoices[nLine] -- Construct the string we're printing
  156. print(sLine) -- Print it
  157. end
  158. -- os.pullEvent keys: up - 200, down - 208, enter - 28
  159. local sEvent, nKey = os.pullEvent("key") -- Using the 1.3 filtering; this will mean only "key" events will pass
  160.  
  161. if nKey == 200 or nKey == 17 then -- Up/w key: move up the menu
  162. if tChoices[nSelection - 1] then -- Check if we can move up
  163. nSelection = nSelection - 1
  164. end
  165. -- Ignore it otherwise
  166. elseif nKey == 208 or nKey == 31 then -- Down/s key: move down the menu
  167. if tChoices[nSelection + 1] then -- Check if we can move down
  168. nSelection = nSelection + 1
  169. end
  170. elseif nKey == 28 then -- Enter key: Selecting a choice
  171. if tActions[nSelection] then
  172. tActions[nSelection]() -- Run the function associated with the action.
  173. else
  174. print("Error: Selection out of bounds: ", nSelection)
  175. read() -- This error is recoverable.
  176. end
  177. end
  178. until false -- Run this loop forever :)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement