Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local p = peripheral.wrap("right")
- --local info = p.getPlayers()
- --local username = info[1].name
- --local pos = p.getPlayerByName(username).position
- redstone.setOutput("left", true)
- i = 1
- function getInfo()
- info = p.getPlayers()
- return info
- end
- function getUsername()
- getInfo()
- info = p.getPlayers()
- username = info[1].name
- return username
- end
- function getPos()
- info = p.getPlayers()
- username = info[1].name
- pos = p.getPlayerByName(username).position
- return pos
- end
- while true do
- print("Iteration: "..i)
- i = i + 1
- getInfo()
- getUsername()
- getPos()
- for key, value in pairs(info) do
- for x, y in pairs(value) do
- print(x..": "..y)
- end
- end
- print(username)
- for A, E in pairs(pos) do
- print(A..": "..E)
- end
- print("Player 1: "..info[1].name)
- sleep(10)
- -- if info ~= nil then
- -- print("Iteration: "..i)
- -- i = i +1
- -- print("Someone is online! Who is it?")
- -- sleep(1)
- -- getPos()
- -- print(getUsername().." has been detected! How close are they?")
- -- if getPos() ~= nil then
- -- pos = p.getPlayerByName(username).position
- -- print(getUsername().." is at coords: "..getPos().x..", "..getPos().y..", "..getPos().z)
- -- if getPos().x >= -2 and getPos().x <= 2
- -- and getPos().y >= 0 and getPos().y <= 3
- -- and getPos().z >= -2 and getPos().z <= 2 then
- -- print(getUsername().." is in the spot. Opening Door")
- -- redstone.setOutput("left", false)
- -- sleep(3)
- -- redstone.setOutput("left", true)
- -- else
- -- print("oooh if only Player were in the spot...")
- -- sleep(1)
- -- end
- -- end
- -- else
- -- print("No one is online -_-")
- -- sleep(1)
- -- end
- end
Advertisement
Add Comment
Please, Sign In to add comment