Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local client = changeme
- local usr = "changeme"
- local pass = "changeme"
- rednet.open("back")
- -- Helper function to split strings at the first line-break ("n").
- -- Returns: Two strings representing the first and second half of the given string.
- local function splitAtLineBreak( toSplit )
- for i = 1, #toSplit do
- local currChar = string.sub( toSplit, i, i )
- if currChar == "n" then
- firstHalf = string.sub( toSplit, 1, i - 1 )
- secondHalf = string.sub( toSplit, i + 1 )
- return firstHalf, secondHalf
- end -- of IF
- end -- of FOR
- end
- while true do
- local id, loginDetails
- repeat
- id, loginDetails = rednet.receive()
- until id == client
- local receivedUser, receivedPass = splitAtLineBreak( loginDetails )
- if receivedUser == usr and receivedPass == pass then
- sleep(5)
- rednet.send(client, "granted")
- else
- sleep(5)
- rednet.send(client, "denied")
- end
- end
Add Comment
Please, Sign In to add comment