Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local radar = peripheral.wrap("left")
- local c = peripheral.wrap("bottom")
- local os = os
- local password = "mog"
- while true do
- local players = radar.getPlayers()
- for i = 1, #players do
- local playerName = players[i]["name"]
- local distance = players[i]["distance"]
- if distance < 3 then
- c.say("hello, " .. playerName .. "! What is the password?")
- os.sleep(3)
- local event, side, player, message = os.pullEvent("chat_message")
- if message == password then
- redstone.setOutput("back", true)
- c.say("Password is correct! Welcome to home !")
- end
- if message == "close" then
- redstone.setOutput("back", false)
- c.say("Goodbye, " .. playerName .. "!")
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement