Advertisement
Guest User

cloud

a guest
Sep 9th, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.32 KB | None | 0 0
  1. function center(sText)
  2.     local w, h = term.getSize()
  3.     local x, y = term.getCursorPos()
  4.     x = math.max(math.floor(( w / 2) - (#sText / 2)), 0)
  5.     term.setCursorPos(x, y)
  6.     print(sText)
  7. end  
  8. rednet.open("top")
  9. term.setBackgroundColor(colors.blue)
  10. term.clear()
  11. term.setCursorPos(1,1)
  12. center("HouseCloud")
  13. term.setCursorPos(22,8)
  14. term.setBackgroundColor(colors.lightBlue)
  15. print("Login")
  16. term.setCursorPos(20,10)
  17. print("Register")
  18. term.setCursorPos(22, 15)
  19. print("Exit")
  20. while true do
  21. local event, button, x, y = os.pullEvent("mouse_click")
  22. if x >= 22 and x < 27 and y == 15 then
  23.    term.setBackgroundColor(colors.black)
  24.    term.clear()
  25.    term.setCursorPos(1,1)
  26.    break
  27. elseif x >= 22 and x < 28 and y == 8 then
  28.     term.clear()
  29.     term.write("Username: ")
  30.     user = read()
  31.     term.write("Password: ")
  32.     pass = read("*")
  33.     print("Logging in...")
  34.     rednet.broadcast("login", user, pass)
  35.     id, message = rednet.receive()
  36.     if message == "nousrexist" then
  37.        print(user, " does not exist!")
  38.        os.sleep(1)
  39.        os.reboot()
  40.     elseif message == "sendestring" then
  41.         local tmpkey = encryption.generateKey(30) -- Makes Session Key
  42.         local key = tostring(tmpkey)
  43.         rednet.broadcast("estringsent", key)
  44.         print("Sucessful!")
  45.     end
  46.   end  
  47. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement