Advertisement
KoopaGaming

Roaming Login

Aug 7th, 2016
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. print("Welcome to AirJoe.")
  2. sleep(2)
  3. print("Your Funeral Starts Here.")
  4. sleep(2)
  5.  
  6.  
  7. local oldpullevent = os.pullevent
  8. local os.pullevent = os.pullEventRaw
  9. local auth_channel = 234 --#Ensure that the auth channel is the same!
  10. local myChannel = 10 --#Any channel the user wishes
  11. local modem = peripheral.wrap("top")
  12. modem.open(myChannel) --#We don't need to open the auth_channel to send messages, only if we need to receive on that channel
  13.  
  14. while true do
  15. term.clear() term.setCursorPos(1,1)
  16. term.write("Username: ")
  17. local username = read() --#Gets the user's input
  18. local password = read("*") --#The asterisk is the masking character
  19.  
  20. local user_table = {["username"] = username, ["password"] = password}
  21. modem.transmit(auth_channel, myChannel, textutils.serialize(user_table)) --#Go ahead and send off the info to the server
  22. while true do --Now we wait for a response
  23. local event, modem_side, sender_channel, reply_channel, message = os.pullEvent("modem_message")
  24. if reply_channel == auth_channel then --#If it is indeed the server that sent the message
  25. if message == "valid" then --#It was indeed a valid username/password combo
  26. printError("Valid username/password!") --#Do whatever you want here + sets the exit error.
  27. os.pullEvent = oldpullevent
  28. error() -- Exit the program
  29.  
  30. else --#Nope, invalid.
  31. print("Invalid username/password!")
  32. sleep(3)
  33. end
  34. end
  35. end
  36. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement