Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- triesRemaining = 3
- function getUsers()
- rednet.broadcast("getUser", "getUser")
- id, msg, prot = rednet.receive()
- if prot == "getUser" then
- return msg
- end
- end
- function updateScreen()
- os.pullEvent("char")
- term.clear()
- term.setCursorPos(1,1)
- uname = getUsers()
- term.clear()
- term.setCursorPos(1,1)
- print("Welcome, " .. uname .."!")
- term.setCursorPos(1,2)
- os.queueEvent("key", 15)
- end
- function confirmPass()
- inp = read("*")
- rednet.broadcast(inp, "pass")
- while true do
- id, msg, prot = rednet.receive()
- if prot == "pass" then
- if msg == "granted" then
- return true
- end
- if msg == "denied" then
- return false
- end
- end
- end
- end
- function getPassword()
- pass = confirmPass()
- if pass == true then
- print("Access granted.")
- triesRemaining = 3
- redstone.setBundledOutput("bottom", colors.red)
- sleep(5)
- redstone.setBundledOutput("bottom", 0)
- else
- triesRemaining = triesRemaining - 1
- print("Incorrect. " .. triesRemaining .. " tries remaining")
- sleep(3)
- if triesRemaining == 0 then
- print("Prepare for your death")
- sleep(0.25)
- redstone.setBundledOutput("bottom", colors.green)
- sleep(1)
- redstone.setBundledOutput("bottom", 0)
- triesRemaining = 3
- end
- end
- end
- term.clear()
- term.setCursorPos(1,1)
- rednet.open("back")
- while true do
- parallel.waitForAll(updateScreen, getPassword)
- term.clear()
- term.setCursorPos(1,1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement