Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("ocs/apis/sensor")
- mySensor = sensor.wrap("left")
- while true do
- targets = mySensor.getTargets()
- player = false;
- for k, v in pairs( targets ) do
- details = mySensor.getTargetDetails(k)
- if details ~= nil and details["IsPlayer"] ~= nil and details["IsPlayer"] then
- pos = details["Position"];
- dist = math.sqrt(math.pow(pos["X"],2) + math.pow(pos["Y"],2) + math.pow(pos["Z"],2))
- if dist <= 40 then
- player = true
- end
- end
- end
- if player then
- redstone.setOutput("right", true)
- else
- redstone.setOutput("right", false)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment