Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Welcome to AirJoe.")
- sleep(2)
- print("Your Funeral Starts Here.")
- sleep(2)
- local oldpullevent = os.pullevent
- local os.pullevent = os.pullEventRaw
- local auth_channel = 234 --#Ensure that the auth channel is the same!
- local myChannel = 10 --#Any channel the user wishes
- local modem = peripheral.wrap("top")
- modem.open(myChannel) --#We don't need to open the auth_channel to send messages, only if we need to receive on that channel
- while true do
- term.clear() term.setCursorPos(1,1)
- term.write("Username: ")
- local username = read() --#Gets the user's input
- local password = read("*") --#The asterisk is the masking character
- local user_table = {["username"] = username, ["password"] = password}
- modem.transmit(auth_channel, myChannel, textutils.serialize(user_table)) --#Go ahead and send off the info to the server
- while true do --Now we wait for a response
- local event, modem_side, sender_channel, reply_channel, message = os.pullEvent("modem_message")
- if reply_channel == auth_channel then --#If it is indeed the server that sent the message
- if message == "valid" then --#It was indeed a valid username/password combo
- printError("Valid username/password!") --#Do whatever you want here + sets the exit error.
- os.pullEvent = oldpullevent
- error() -- Exit the program
- else --#Nope, invalid.
- print("Invalid username/password!")
- sleep(3)
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement