Advertisement
Guest User

startup

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