Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- oldpull = os.pullEvent
- os.pullEvent = os.pullEventRaw -- remove the CTRL + T escape
- -- Local variables
- local cmpid = os.getComputerID()
- local locker = true -- Technically I no longer use this varible. it used to define the loop for my login.
- local failed = true
- local attempted_login = true
- local password_server = 10 -- change to the ID of your password server computer
- local moside = "top" -- This is your modem location :- top, bottom, left, right, back or front
- print("Computer ID : ".. cmpid)
- rednet.open(moside) -- open the Rednet modem.
- while true do -- infinite loop
- attempted_login = false -- reset the varible
- term.clear()
- term.setCursorPos(1,1)
- print("Welcome to a Client PC")
- print("What would you like to do?")
- print("[1] Login (*)")
- print("[2] Shutdown")
- -- end of the menu
- write("> ")
- local input = read()
- if input == "2" then -- reverse order shall we shut down ?
- os.shutdown()
- elseif input == "1" then -- if not then lets do something maybe ?
- attempted_login = true
- print("Please login...")
- -- Username
- write("Username: ")
- local username = read() -- Get input of Username
- -- Password
- write("Password: ")
- local password = read("*") -- Get masked input of Password
- local testmessage = username .. " " .. password -- make our rednet message with seperator
- if debug then print(testmessage);sleep(5); end -- Debug testing to check the message
- rednet.send(password_server, testmessage, true)
- senderId, message, distance = rednet.receive(5)
- if message == "valid" then -- did the server send the message "valid" ?
- failed = false
- --[[
- locker = false -- here is the non used Locker again, at this point it would unlock us from the loop.
- -- the while true do makes that line obsolete.
- --]]
- term.clear()
- term.setCursorPos(1,1)
- print("Welcome ", username) -- Welcome the user.
- printError("Command restored")
- os.pullEvent = oldpull
- error()
- --[[ This next section is my door opening server. Send the open and close commands
- -- to the door server, plus the wait time of 6 seconds to get out the terminal and through the door
- rednet.send(17, "open")
- sleep(6)
- rednet.send(17, "close")
- --]]
- else -- The server sent a non valid respone.
- print("Invalid Username or Password.")
- sleep(3)
- end
- -- If you did not type 1 or 2... I have no idea...
- else
- print("Command not recognised...")
- sleep(2)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement