Advertisement
Guest User

startup

a guest
Nov 20th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.90 KB | None | 0 0
  1. function banner()
  2.     print("Welcome to SwatDoge's chat program")
  3.     print("")
  4. end
  5.  
  6. function cls()
  7.     term.clear()
  8.     term.setCursorPos(1, 1)
  9. end
  10.    
  11. function linecls()
  12.     linepos,line = term.getCursorPos()
  13.     line = line - 1
  14.     term.setCursorPos(1, line)
  15.     term.clearLine()
  16.     line = line + 1
  17.     term.setCursorPos(1, line)
  18. end
  19.  
  20. function name()
  21.     cls()
  22.     write("What would you like your name to be? ")
  23.     account_name = read()
  24.     if account_name == nil then
  25.     account_name = admin
  26.     password()
  27.     end
  28.     password()
  29. end
  30.  
  31. function password()
  32.     cls()
  33.     write("Welcome "..account_name..", Type a password you'd want to use: ")
  34.     write("")
  35.     account_password = read()
  36.     print(account_password)
  37.     if account_password == nil then
  38.     account_password = admin
  39.     end
  40.     cls()
  41.     login()
  42. end
  43.  
  44. function first_name()
  45.     if account_name == nil then
  46.       name()
  47.     else
  48.       print(name)
  49.       cls()
  50.       login()
  51.     end
  52. end
  53.  
  54. function login()
  55.     local account_name_check
  56.     local account_password_check
  57.     print("Login with your information.")
  58.     write("Username: ")
  59.     account_name_check = read()
  60.     write("Password: ")
  61.     account_password_check = read()
  62.  
  63.     if (account_name_check == account_name) and (account_password_check == account_password) then
  64.       cls()
  65.       chat()
  66.     else
  67.       cls()
  68.       print("wrong username or password")
  69.       login()
  70.     end
  71.     end
  72.  
  73.     function chat()
  74.       write("send your message: ")
  75.       message = read()
  76.       linecls()
  77.     if message ~= nil or message ~= 9991 then
  78.       rednet.send(5, account_name .. ": " .. message, "sender")
  79.     end
  80.     id, reply = rednet.receive("swatdoge")
  81.     print(reply)
  82.     message = 9991
  83.     chat()
  84.     end
  85.  
  86. if pocket then
  87.   rednet.open("back")
  88. else
  89.   rednet.open("top")
  90. end
  91.  
  92. local account_password
  93. local account_name
  94. banner()
  95. first_name()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement