xXm0dzXx

Untitled

Apr 22nd, 2012
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. menu = 1
  2. x,y = term.getSize()
  3.  
  4. if not fs.exists("N-LeafG") then
  5. fs.makeDir("N-LeafG")
  6. end
  7.  
  8. function Message(text, text2)
  9. for i=1,x-1 do
  10. term.setCursorPos(i, y-3)
  11. write("-")
  12. end
  13.  
  14. term.setCursorPos(1, y-2)
  15. print(text)
  16. term.setCursorPos(1, y-1)
  17. print(text2)
  18. local event, a, b = os.pullEvent("key")
  19. for i=1,x-1 do
  20. term.setCursorPos(i, y-3)
  21. write(" ")
  22. end
  23. for i=1,x-1 do
  24. term.setCursorPos(i, y-2)
  25. write(" ")
  26. end
  27. for i=1,x-1 do
  28. term.setCursorPos(i, y-1)
  29. write(" ")
  30. end
  31. end
  32.  
  33. local function cPrint(text)
  34. local x2,y2 = term.getCursorPos()
  35. term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
  36. print(text)
  37. end
  38.  
  39. function game()
  40. term.clear()
  41. term.setCursorPos(1,y-3)
  42. Message("Hello, there!", "Glad to meet you!")
  43. Message("Welcome to the world of NeXiMoN", "My name is OAK.")
  44. end
  45.  
  46. function menu()
  47. term.clear()
  48. term.setCursorPos(1,1)
  49. cPrint("NeXiMoN Leaf Green")
  50. cPrint("")
  51. if menu == 1 then
  52. cPrint("[ Load Game ]")
  53. else cPrint("Load Game")
  54.  
  55. if menu == 2 then
  56. cPrint("[ Reset Data ]")
  57. else cPrint("Reset Data") end
  58.  
  59. if menu == 3 then
  60. cPrint("[ Quit ]")
  61. else cPrint("Quit") end
  62. end
  63.  
  64. menu()
  65.  
  66. while true do
  67. local e,key = os.pullEvent( "key" )
  68. if key == 17 or key == 200 then
  69. if menu > 1 then
  70. menu = menu - 1
  71. menu()
  72. end
  73. elseif key == 31 or key == 208 then
  74. if menu < 3 then
  75. menu = menu + 1
  76. menu()
  77. end
  78. elseif key == 28 then
  79. break
  80. end
  81. end
  82. end
  83.  
  84. if menu == 3 then
  85. os.reboot()
  86. elseif menu == 2 then
  87. term.clear()
  88. term.setCursorPos(1,1)
  89. write("Are you sure? (y/n)")
  90. input = read()
  91. if input == "y" then
  92. shell.run("rm", "N-LeafG")
  93. print("Deleted!")
  94. sleep(1)
  95. os.reboot()
  96. else
  97. os.reboot()
  98. end
  99. elseif menu == 1 then
  100. game()
  101. end
Advertisement
Add Comment
Please, Sign In to add comment