Advertisement
matthewkk91

Untitled

Jun 26th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.67 KB | None | 0 0
  1. --This is my code for Auto-Spawner I am building
  2.  
  3. --verison of spawner
  4.  
  5.  
  6. ----This is the function to center text
  7. slc = 0
  8.  
  9. local w, h = term.getSize()
  10.  
  11. --function to centertext
  12.  
  13. local function cenText(text,y)
  14.     term.setCursorPos(w/2-#text/2,y)
  15.     term.write(text)
  16. end
  17.  
  18. local function setup()
  19.     term.clear()
  20.     term.setCursorPos(1,1)
  21. end
  22. local function verison()
  23. term.setTextColor(colors.yellow)
  24. cenText("Auto-Spawner Verison 1.0",1)
  25. end
  26.  
  27.  
  28. menuOptions = {
  29.     [1]= {text = "(1)Zombie"},
  30.     [2]= {text = "(2)Blaze"},
  31.     [3]= {text = "(3)Skelton"},
  32.     [4]= {text = "(4)Sheep"},
  33.     [5]= {text = "(5)Reset"},
  34. }
  35.  
  36.  
  37. local function mainMenu()
  38.     setup()
  39.     verison()
  40.     term.setCursorPos(1,5)
  41.     term.setTextColor(colors.white)
  42.         for i,v in ipairs(menuOptions) do
  43.             i = 1, #menuOptions
  44.             print(v.text)
  45.         end
  46.     term.setCursorPos(1,11)
  47.     term.setTextColor(colors.yellow)
  48.     print("Please input the number that you want to spawn:")
  49.     term.setTextColor(colors.white)
  50. end
  51. local function selection()
  52. input = read()
  53.     if input == ("1") then
  54.         slc = 1
  55.        
  56.     elseif input ==("2")then
  57.         slc = 2
  58.     elseif input ==("3") then
  59.         slc = 3
  60.     elseif input ==("4") then
  61.         slc = 4
  62.     elseif input ==("5") then
  63.         slc = 5
  64.     else
  65.         sleep(2)
  66.         term.clear()
  67.         slc = 0
  68.     end
  69. end
  70.  
  71. local function mainMenu()
  72.     setup()
  73.     verison()
  74.     term.setCursorPos(1,5)
  75.     term.setTextColor(colors.white)
  76.         for i,v in ipairs(menuOptions) do
  77.             i = 1, #menuOptions
  78.             print(v.text)
  79.         end
  80.     term.setCursorPos(1,11)
  81.     term.setTextColor(colors.yellow)
  82.     print("Please input the number that you want to spawn:")
  83.     term.setTextColor(colors.white)
  84.     selection()
  85. end
  86.  
  87.  
  88. while true do
  89.     if slc == 0 then
  90.  
  91.         mainMenu()
  92.     end
  93.  
  94.  
  95. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement