Advertisement
colhaydutu

etvd

Jan 9th, 2024 (edited)
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. local radar = peripheral.wrap("left")
  2. local c = peripheral.wrap("bottom")
  3. local os = os
  4.  
  5. local password = "mog"
  6.  
  7. while true do
  8. local players = radar.getPlayers()
  9.  
  10. for i = 1, #players do
  11. local playerName = players[i]["name"]
  12. local distance = players[i]["distance"]
  13.  
  14. if distance < 3 then
  15. c.say("hello, " .. playerName .. "! What is the password?")
  16. os.sleep(3)
  17.  
  18. local event, side, player, message = os.pullEvent("chat_message")
  19.  
  20. if message == password then
  21. redstone.setOutput("back", true)
  22. c.say("Password is correct! Welcome to home !")
  23. end
  24.  
  25. if message == "close" then
  26. redstone.setOutput("back", false)
  27. c.say("Goodbye, " .. playerName .. "!")
  28. end
  29. end
  30. end
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement