Advertisement
Guest User

Untitled

a guest
Mar 18th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.92 KB | None | 0 0
  1. local tChoices = {}
  2. tChoices[0] = 'Squelette'
  3. tChoices[0] = 'Golem de fer'
  4. tChoices[0] = 'Blaze'
  5. tChoices[0] = '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 "| Mining Reports |"
  37. print(sSeperator)
  38. print "Today I mined 32 iron in a deep mine under my"
  39. print "house. I got attacked by a zombie on my way out"
  40. print "of the mine. I had to drop all my iron so I could"
  41. print "Run fast enough to outrun the zombie."
  42.  
  43. term.setCursorPos(1, nTermY) -- Move the cursor to the bottom
  44. write(" [Press enter to return to main menu]")
  45. read()
  46. end
  47.  
  48. tActions[2] = function()
  49. term.clear()
  50. term.setCursorPos(1, 1)
  51. print(sSeperator)
  52. print "| New Base of Operations |"
  53. print(sSeperator)
  54. print "I have moved out of my home into a new base in"
  55. print "the mountain up north. I will be studying new"
  56. print "ways to produce energy to power my technology."
  57.  
  58. term.setCursorPos(1, nTermY) -- Move the cursor to the bottom
  59. write(" [Press enter to return to main menu]")
  60. read()
  61. end
  62.  
  63. tActions[3] = function()
  64. term.clear()
  65. term.setCursorPos(1, 1)
  66. print(sSeperator)
  67. print "| Energy Project |"
  68. print(sSeperator)
  69. print "I have discovered a new type of energy that has"
  70. print "the power output to power 10 cities all at once."
  71. print ""
  72. print "I ran into one problem once i discovered this new"
  73. print "type of energy. I couldnt find a way to get it"
  74. print "stable enough to be safe. I had to flee the area."
  75. print "After i left the area my base exploded and made"
  76. print "the mountain into...well....lets just say its not"
  77. print "a mountain anymore....."
  78.  
  79. term.setCursorPos(1, nTermY) -- Move the cursor to the bottom
  80. write(" [Press enter to return to main menu]")
  81. read()
  82. end
  83.  
  84. table.insert(tActions, os.shutdown) -- Insert the shutdown function at the end to compliment the "Shutdown" menu item :)
  85.  
  86. -- Do the above for the remaining
  87.  
  88. local nSelection = 0 -- The current selection defaults at 0
  89. repeat
  90. term.setCursorPos(1, 1)
  91. term.clear()
  92. print(sSeperator)
  93. print("| FantomQc pour vous servir! |")
  94. print(sSeperator)
  95.  
  96. for nLine = 0, #tChoices do -- Iterate through the possible potions, and print them, marking the chosen one
  97. local sLine = " "
  98. if nSelection == nLine then
  99. sLine = ">"
  100. end
  101. local sLineNum = tostring(nLine)
  102. if #sLineNum < 2 then
  103. sLineNum = "0" .. sLineNum -- Prepend a 0 if it's too short
  104. end
  105. sLine = sLine .. "[" .. sLineNum .. "]" .. " " .. tChoices[nLine] -- Construct the string we're printing
  106. print(sLine) -- Print it
  107. end
  108. -- os.pullEvent keys: up - 200, down - 208, enter - 28
  109. local sEvent, nKey = os.pullEvent("key") -- Using the 1.3 filtering; this will mean only "key" events will pass
  110.  
  111. if nKey == 200 or nKey == 17 then -- Up/w key: move up the menu
  112. if tChoices[nSelection - 1] then -- Check if we can move up
  113. nSelection = nSelection - 1
  114. end
  115. -- Ignore it otherwise
  116. elseif nKey == 208 or nKey == 31 then -- Down/s key: move down the menu
  117. if tChoices[nSelection + 1] then -- Check if we can move down
  118. nSelection = nSelection + 1
  119. end
  120. elseif nKey == 28 then -- Enter key: Selecting a choice
  121. if tActions[nSelection] then
  122. tActions[nSelection]() -- Run the function associated with the action.
  123. else
  124. print("Error: Selection out of bounds: ", nSelection)
  125. read() -- This error is recoverable.
  126. end
  127. end
  128. until false -- Run this loop forever :)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement