Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- players = {"Edowa43"}
- minY = -1
- maxY = 5
- maxDistance = 10
- sensor = peripheral.wrap("right")
- loop = true
- while loop==true do
- if (redstone.getInput("top") == true) then
- loop = false
- end
- open = false
- p = sensor.getPlayers()
- for j=1,#p do
- name = p[j].name
- found = false
- for i=1,#players do
- if (players[i] == name) then
- found = true
- end
- end
- if (found == true) then
- coord = sensor.getPlayerByName(name).all().position
- distance = coord.x*coord.x+coord.z*coord.z
- distance = math.sqrt(distance)
- if (distance < maxDistance) then
- print("distance OK"..coord.y)
- if (coord.y > minY) then
- print("Y test")
- if (coord.y < maxY) then
- print("Y ok")
- open = true
- end
- end
- end
- end
- end
- redstone.setOutput("back", open)
- sleep(0.2)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement