Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("top")
- local serverId
- print("Connecting to server...")
- rednet.broadcast("","cdrive-findserver")
- repeat
- local id,msg,pro = rednet.receive("cdrive-gotserver",3)
- if pro == "cdrive-gotserver" then
- serverId = id
- print("Success! Connected to server id "..serverId)
- elseif id == nil then
- printError("Failed to connect to server!")
- return
- end
- until serverId
- print("Drawing login UI...")
- local function drawLoginUI()
- term.setCursorPos(2,2)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.gray)
- term.clear()
- term.write("cDrive Login")
- term.setCursorPos(2,4)
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.gray)
- term.write(" Username ")
- term.setCursorPos(2,6)
- term.write(" Password ")
- term.setCursorPos(2,8)
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.lightGray)
- term.write(" Login ")
- term.setCursorPos(11,8)
- term.write(" Cancel ")
- term.setCursorPos(21,8)
- term.write(" Sign Up ")
- end
- local function drawSignupUI()
- term.setBackgroundColor(colors.white)
- term.clear()
- term.setCursorPos(2,2)
- term.setTextColor(colors.gray)
- term.write("Loading...")
- rednet.send(serverId, nil, "cdrive-requestwave")
- local id, wave, pro = rednet.receive("cdrive-gotwave",3)
- term.clear()
- term.setCursorPos(2,2)
- term.write("When you sign up, your wave will be "..wave)
- sleep(100)
- end
- local username = ""
- local password = ""
- local function loginButtons()
- while true do
- local event, b, x, y = os.pullEvent("mouse_click")
- if x >= 11 and x <= 19 and y == 8 then
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- return
- elseif x >= 21 and x <= 30 and y == 8 then
- drawSignupUI()
- return
- elseif x >= 2 and x <= 29 and y == 4 then
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.lightGray)
- term.setCursorPos(3,4)
- term.write(string.rep(" ", 27))
- term.setCursorPos(3,4)
- username = read()
- elseif x >= 2 and x <= 29 and y == 6 then
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.lightGray)
- term.setCursorPos(3,6)
- term.write(string.rep(" ", 27))
- term.setCursorPos(3,6)
- password = read("\7")
- end
- end
- end
- drawLoginUI()
- loginButtons()
- rednet.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement