Advertisement
Guest User

startup

a guest
Nov 18th, 2018
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.78 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 name()
  12.     account_name = user
  13.     cls()
  14.     write("What would you like your name to be? ")
  15.     account_name = read()
  16.     password()
  17. end    
  18.  
  19. function password()
  20.     account_password = admin
  21.     cls()
  22.     write("Welcome "..account_name..", Type a password you'd want to use: ")
  23.     write("")
  24.     account_password = read()
  25.     cls()
  26.     login()
  27. end
  28.    
  29. function first_name()
  30.     if account_name == nil then
  31.     name()
  32.     else
  33.     print(name)
  34.     cls()
  35.     login()
  36.     end
  37. end
  38.  
  39. function login()
  40.     local account_name_check
  41.     local account_password_check
  42.     print("Login with your information.")
  43.     write("Username: ")
  44.     account_name_check = read()
  45.     write("Password: ")
  46.     account_password_check = read()
  47.    
  48.     if (account_name_check == account_name) and (account_password_check == account_password) then
  49.     cls()
  50.     chat()
  51.     else
  52.     cls()
  53.     print("wrong username or password")
  54.     login()
  55.     end
  56.     end
  57.    
  58.     function chat()
  59.     write("send your message: ")
  60.     message = read()
  61.     if message ~= nil then
  62.     rednet.send(21, account_name .. ": " .. message)
  63.     end
  64.     end
  65.  
  66.     while message ~= nil do
  67.     id, reply = rednet.receive(1)
  68.     if reply == "swatdoge" then
  69.     print("bericht ontvangen")
  70.         rednet.send(21, "ontvangen")
  71.         id, reply = rednet.receive()
  72.         if reply ~= nil or reply ~= "swatdoge" then
  73.         print(reply)
  74.         end
  75.        
  76.     message = nil
  77.     chat()
  78.     end
  79.     end
  80.  
  81. if pocket then
  82. rednet.open("back")
  83. else
  84. rednet.open("top")
  85. end
  86.  
  87. local account_password
  88. local account_name
  89. banner()
  90. first_name()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement