Advertisement
RemiCraft

Menu

Jul 12th, 2021 (edited)
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.47 KB | None | 0 0
  1. os.loadAPI("touchpoint")
  2. local mainMenu = touchpoint.new()
  3. local gamesMenu = touchpoint.new()
  4. local t
  5.  
  6. --Basic Functions--
  7. local function update()
  8.     shell.run("rm startup")
  9.     shell.run("pastebin get wiUs761K startup")
  10.     shell.run("startup")
  11. end
  12. local function clear()
  13.     term.clear()
  14.     term.setCursorPos(1,1)
  15. end
  16.  
  17. --Applications--
  18. local function adventure()
  19.     term.setTextColor(colors.white)
  20.     term.setBackgroundColor(colors.black)
  21.     clear()
  22.     term.write("* Type quit to exit *")
  23.     term.setCursorPos(1,2)
  24.     shell.run("adventure")
  25. end
  26. local function cookieClicker()
  27.     clear()
  28.     shell.run("cclicker")
  29. end
  30.  
  31. ---Set Up Pages--
  32. local function openMainMenu()
  33.     t = mainMenu
  34. end
  35. local function openGamesMenu()
  36.     t = gamesMenu
  37. end
  38.  
  39. --Set Up Buttons--
  40. do
  41.     --Main Menu--
  42.     mainMenu:add("Main Menu", update, 1, 1, 26, 1, colors.black, colors.black)
  43.     --mainMenu:add("Test", testAction, 2, 3, 25, 3)
  44.     mainMenu:add("Games", openGamesMenu, 15, 19, 25, 19)
  45.  
  46.     --Games Menu--
  47.     gamesMenu:add("Games", update, 1, 1, 26, 1, colors.black, colors.black)
  48.     gamesMenu:add("Minecraft", adventure, 2, 3, 25, 3)
  49.     gamesMenu:add("Cookie Clicker", cookieClicker, 2, 5, 25, 5)
  50.     gamesMenu:add("Main Menu", openMainMenu, 2, 19, 12, 19)
  51. end
  52.  
  53. openMainMenu()
  54. while true do
  55.     t:draw()
  56.     local event, p1 = t:handleEvents(os.pullEvent())   ---button_click, name
  57.     if event == "button_click" then
  58.         --remove toggling and simplify button running
  59.         t.buttonList[p1].func()
  60.     end
  61. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement