AdventurousMR

.menu

Sep 25th, 2021 (edited)
471
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.54 KB | None | 0 0
  1. term.clear()
  2. term.setCursorPos(1,1)
  3. print("##############################")
  4. term.setCursorPos(1,2)
  5.  
  6. function drawMenu()
  7.     term.setCursorPos(1,13)
  8.     print("Command   ")
  9.    
  10.     term.setCursorPos(1,15)
  11.     print("Ports    ")
  12.  
  13.     term.setCursorPos(1,17)
  14.     print("Unavailable    ")
  15. end
  16.  
  17. function drawOption1()
  18.     term.setCursorPos(1,13)
  19.     print("[Command]")
  20. end
  21.  
  22. function drawOption2()
  23.     term.setCursorPos(1,15)
  24.     print("[Ports]")
  25. end
  26.  
  27. function drawOption3()
  28.     term.setCursorPos(1,17)
  29.     print("[Unavailable]")
  30. end
  31.  
  32. print("    ___         __  ")
  33. print("   /   |  _____/ /_ ")
  34. print("  / /| | / ___/ __ \\")
  35. print(" / ___ |(__  ) / / /")
  36. print("/_/  |_/____/_/ /_/  1.0.2")
  37.  
  38. drawMenu()
  39. term.setCursorPos(1,13)
  40. print("[Command]")
  41.  
  42. term.setCursorPos(1,8)
  43. print("##############################")
  44. print("Main Menu")
  45. print("Pick a page to go to.")
  46. print("######################")
  47. term.setCursorPos(1,12)
  48.  
  49. local buttonNum = -1
  50. while true do
  51.   local event, key, isHeld = os.pullEvent("key")
  52.     if key == keys.up then
  53.         if buttonNum >= -1 then
  54.             buttonNum = buttonNum - 1
  55.         end
  56.     end
  57.  
  58.     if key == keys.down then
  59.         if buttonNum <= -1 then
  60.             buttonNum = buttonNum + 1
  61.         end
  62.     end
  63.  
  64.     if key == keys.enter then
  65.         if buttonNum == -1 then
  66.             shell.run(".command")
  67.             break
  68.         elseif buttonNum == 0 then
  69.             shell.run(".PortConnectionLost")
  70.             break
  71.         end
  72.     end
  73.  
  74.     if buttonNum == -1 then
  75.         drawMenu()
  76.         drawOption1()
  77.     elseif buttonNum == 0 then
  78.         drawMenu()
  79.         drawOption2()
  80.     elseif buttonNum == 1 then
  81.         drawMenu()
  82.         drawOption3()
  83.     end
  84.  
  85. end
Add Comment
Please, Sign In to add comment