Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. -- MENU CREDS TO BIGSHINYTOYS
  2. term.clear()
  3. term.setCursorPos(1, 1)
  4. local ok, err = pcall( function()
  5. if http then
  6. aa = aa or {}
  7. local a = http.get("http://api.dannysmc.com/files/apis/discover.lua")
  8. a = a.readAll()
  9. local env = {}
  10. a = loadstring(a)
  11. local env = getfenv()
  12. setfenv(a,env)
  13. local status, err = pcall(a, unpack(aa))
  14. if (not status) and err then
  15. printError("Error loading api")
  16. return false
  17. end
  18. local returned = err
  19. env = env
  20. _G["discover"] = env
  21. end
  22. end)
  23. if not ok then
  24. error("Could not install API")
  25. end
  26.  
  27. print("Powered by Discover API by DannySMc")
  28. print("")
  29. print("")
  30. print("")
  31. write("Username : ")
  32. local duser = read()
  33. write("Password : ")
  34. local dpass = read("")
  35.  
  36.  
  37. local status, err = Discover.User:Login("".. duser .. "", "".. dpass .. "")
  38. if not status then
  39. print(tostring(err))
  40. end
  41.  
  42. local status = Discover.User:LoggedIn()
  43. if status then
  44. term.setTextColor(colors.green)
  45. print("Logged in")
  46. term.setTextColor(colors.white)
  47. term.clear()
  48. else
  49. term.setTextColor(colors.red)
  50. print("User is not logged in")
  51. term.setTextColor(colors.white)
  52. end
  53.  
  54. local function menu(...) -- ver 0.1
  55. local sel = 1
  56. local list = {...}
  57. local offX,offY = term.getCursorPos()
  58. local curX,curY = term.getCursorPos()
  59. while true do
  60. if sel > #list then sel = 1 end
  61. if sel < 1 then sel = #list end
  62. for i = 1,#list do
  63. term.setCursorPos(offX,offY+i-1)
  64. if sel == i then
  65. print("["..list[i].."]") -- very customisible example print(">"..list[i])
  66. else
  67. print(" "..list[i].." ") -- very customisible
  68. end
  69. end
  70. while true do
  71. local e,e1,e2,e3,e4,e5 = os.pullEvent()
  72. if e == "key" then
  73. if e1 == 200 then -- up key
  74. sel = sel-1
  75. break
  76. end
  77. if e1 == 208 then -- down key
  78. sel = sel+1
  79. break
  80. end
  81. if e1 == 28 then
  82. term.setCursorPos(curX,curY)
  83. return list[sel],sel
  84. end
  85. end
  86. end
  87. end
  88. end
  89. -- Example Usage
  90. print("Please select Option")
  91. local selection = menu("Report","Infomation/Help","Exit")
  92. if selection == "Report" then
  93. shell.run("/.dtest/report");
  94. elseif selection == "Information/Help" then
  95. shell.run("/.dtest/info");
  96. elseif selection == "Exit" then
  97. end
  98. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement