jig487

GUIstuff

Jul 28th, 2021 (edited)
452
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Random quests pop up on message app
  2. --Achievements / collectables app
  3. --Radar app
  4. --Note pad (quest log)
  5.  
  6. --Put functions in a table and change apps that way
  7.  
  8. term.clear()
  9.  
  10. local width,height = term.getSize()
  11.  
  12. local function newButton(xStart,yStart,label)
  13.     term.setCursorPos(xStart,yStart)
  14.     term.write("["..label.."]")
  15.     local xEnd,yEnd = term.getCursorPos()
  16.     return {xStart, yStart, xEnd, yEnd, label}
  17. end
  18.  
  19. local function waitButtonPressed(list) --Returns index # of button pressed from button press
  20.     local event, button, x, y = os.pullEvent( "mouse_click" )
  21.     for i = 1, #list do
  22.         if x >= list[i][1] and x <= list[i][3] and y >= list[i][2] and y <= list[i][4] then
  23.             return list[i][5]
  24.         end
  25.     end
  26.     return false
  27. end
  28.  
  29. local function setRadarScreen()
  30.     term.clear()
  31.     while true do
  32.         local bList = { newButton(1,1,"Main"), newButton(1,2,"Set Frequency") }
  33.         local bChoice = waitButtonPressed(bList)
  34.         while bChoice == false do
  35.             bChoice = waitButtonPressed(bList)
  36.         end
  37.         if bChoice == "Set Frequency" then
  38.             term.setCursorPos(1,height*0.5)
  39.             term.clear()
  40.             term.write("Hahaha loser >:)")
  41.         elseif bChoice == "Main" then
  42.             return "Main"
  43.         else
  44.             term.setCursorPos(1,height*0.5)
  45.             term.write("Uknown input")
  46.         end
  47.     end
  48. end
  49.  
  50. local function setMessageScreen()
  51.     term.clear()
  52.     while true do
  53.         local bList = { newButton(1,1,"Main") }
  54.         term.setCursorPos(1,2)
  55.         print("Inbox:")
  56.         print("from: Tutorial bot { Hello! Please read me' }")
  57.         print("from: Uknown { 'Hot single robots near you'}")
  58.         bChoice = waitButtonPressed(bList)
  59.         while bChoice == false do
  60.             bChoice = waitButtonPressed(bList)
  61.         end
  62.         if bChoice == "Main" then
  63.             return "Main"
  64.         end
  65.     end
  66. end
  67.  
  68. local function setMainScreen()
  69.     term.clear()
  70.     while true do
  71.         local bList = { newButton(1,1,"Radar"), newButton(1,2,"Achievements"), newButton(1,3,"Messages") }
  72.         local bChoice = waitButtonPressed(bList)
  73.         while bChoice == false do
  74.             bChoice = waitButtonPressed(bList)
  75.         end
  76.         if bChoice == "Radar" then
  77.             return "Radar"
  78.         elseif bChoice == "Achievements" then
  79.             return "Achievements"
  80.         elseif bChoice == "Messages" then
  81.             return "Messages"
  82.         else
  83.             return false
  84.         end
  85.     end
  86. end
  87.  
  88. local function setAchievenemtScreen()
  89.     term.clear()
  90.     while true do
  91.         local bList = { newButton(1,1,"Main") }
  92.         term.setCursorPos(1,2)
  93.         print("Achievements:")
  94.         print("Are are currently a loser with")
  95.         print("nothing notable about you. Great")
  96.         print("job, bud.")
  97.         local bChoice = waitButtonPressed(bList)
  98.         while bChoice == false do
  99.             bChoice = waitButtonPressed(bList)
  100.         end
  101.         if bChoice == "Main" then
  102.             return "Main"
  103.         end
  104.     end
  105. end
  106.  
  107. local targetFrequency = 100
  108. local bChoice = setMainScreen()
  109. while true do
  110.     if bChoice == "Main" then
  111.         bChoice = setMainScreen()
  112.     elseif bChoice == "Achievements" then
  113.         bChoice = setAchievenemtScreen()
  114.     elseif bChoice == "Radar" then
  115.         bChoice = setRadarScreen()
  116.     elseif bChoice == "Messages" then
  117.         bChoice = setMessageScreen()
  118.     elseif bChoice == "Notes" then
  119.         bChoice = setNoteScreen()
  120.     end
  121. end
RAW Paste Data