Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- MENU CREDS TO BIGSHINYTOYS
- term.clear()
- term.setCursorPos(1, 1)
- local ok, err = pcall( function()
- if http then
- aa = aa or {}
- local a = http.get("http://api.dannysmc.com/files/apis/discover.lua")
- a = a.readAll()
- local env = {}
- a = loadstring(a)
- local env = getfenv()
- setfenv(a,env)
- local status, err = pcall(a, unpack(aa))
- if (not status) and err then
- printError("Error loading api")
- return false
- end
- local returned = err
- env = env
- _G["discover"] = env
- end
- end)
- if not ok then
- error("Could not install API")
- end
- print("Powered by Discover API by DannySMc")
- print("")
- print("")
- print("")
- write("Username : ")
- local duser = read()
- write("Password : ")
- local dpass = read("")
- local status, err = Discover.User:Login("".. duser .. "", "".. dpass .. "")
- if not status then
- print(tostring(err))
- end
- local status = Discover.User:LoggedIn()
- if status then
- term.setTextColor(colors.green)
- print("Logged in")
- term.setTextColor(colors.white)
- term.clear()
- else
- term.setTextColor(colors.red)
- print("User is not logged in")
- term.setTextColor(colors.white)
- end
- local function menu(...) -- ver 0.1
- local sel = 1
- local list = {...}
- local offX,offY = term.getCursorPos()
- local curX,curY = term.getCursorPos()
- while true do
- if sel > #list then sel = 1 end
- if sel < 1 then sel = #list end
- for i = 1,#list do
- term.setCursorPos(offX,offY+i-1)
- if sel == i then
- print("["..list[i].."]") -- very customisible example print(">"..list[i])
- else
- print(" "..list[i].." ") -- very customisible
- end
- end
- while true do
- local e,e1,e2,e3,e4,e5 = os.pullEvent()
- if e == "key" then
- if e1 == 200 then -- up key
- sel = sel-1
- break
- end
- if e1 == 208 then -- down key
- sel = sel+1
- break
- end
- if e1 == 28 then
- term.setCursorPos(curX,curY)
- return list[sel],sel
- end
- end
- end
- end
- end
- -- Example Usage
- print("Please select Option")
- local selection = menu("Report","Infomation/Help","Exit")
- if selection == "Report" then
- shell.run("/.dtest/report");
- elseif selection == "Information/Help" then
- shell.run("/.dtest/info");
- elseif selection == "Exit" then
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement