Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function center(y,str)
- local w,h = term.getSize()
- local x = (w/2) - (#str/2)
- term.setCursorPos(x,y)
- print(str)
- end
- function render()
- term.setBackgroundColor(colors.white)
- term.clear()
- term.setCursorPos(1,1)
- paintutils.drawLine(1,1,51,1,colors.lightGray)
- term.setCursorPos(1,1)
- term.setTextColor(colors.white)
- center(1,"Venatus reLIVE")
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- end
- function renderstart()
- render()
- center(3,"Please select what you want to do.")
- center(4,"Press the button on your keyboard to continue.")
- center(6,"[L] Login")
- center(7,"[C] Create")
- center(8,"[E] Exit")
- end
- function renderlogin()
- render()
- center(3,"Please input the following information.")
- end
- renderstart()
- local bRunning = true
- while bRunning do
- local e,key = os.pullEvent("key")
- if key == keys.l then
- renderlogin()
- term.setCursorPos(2,5)
- write("Username: ")
- local username = read()
- term.setCursorPos(2,6)
- write("Password: ")
- local password = read("*")
- local auth = shell.run("auth "..username.." "..password)
- if auth == true then
- render()
- center(5,"Login successful.")
- center(6,"Welcome back, "..username..".")
- sleep(3)
- local bRunning = false
- _G.session = {active = true, user = username, pass = password}
- return
- elseif auth == false then
- render()
- center(5,"Login error.")
- center(6,"Either username/password is wrong or server is down.")
- sleep(3)
- local bRunning = false
- return
- end
- elseif key == keys.c then
- render()
- center(2,"Input the following information.")
- term.setCursorPos(2,4)
- write("Username: ")
- local username = read()
- term.setCursorPos(2,5)
- write("Password: ")
- local password = read("*")
- local new = shell.run("newuser "..username.." "..password)
- if new == true then
- render()
- center(5,"The account '"..username.."' has been created.")
- center(6,"We hope you enjoy Venatus reLIVE.")
- sleep(3)
- local bRunning = false
- _G.session = {active = true, user = username, pass = password}
- return
- elseif new == "test" then
- render()
- center(5,"There was an error processing your request.")
- center(6,"Either a user already exists with that name or the")
- center(7,"server is offline.")
- sleep(3)
- local bRunning = false
- return
- end
- elseif key == keys.e then
- local bRunning = false
- return
- end
- end
Add Comment
Please, Sign In to add comment