Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("ocs/apis/sensor")
- s = sensor.wrap("top")
- function playerRange(range, height)
- local result = nil
- x = s.getTargets()
- for k, v in pairs(x) do
- if v.Name == "Player" then
- local x = math.floor(math.abs(v.Position.X))
- local z = math.floor(math.abs(v.Position.Z))
- local y = math.floor(v.Position.Y)
- if y <= height and y >= 0 then
- if (x <= range) or (z <= range) then
- result = true
- else local result = false
- end
- end
- end
- end
- return result
- end
- while true do
- while playerRange(5,5) do
- rs.setOutput("right", true)
- end
- rs.setOutput("right", false)
- end
Advertisement
Add Comment
Please, Sign In to add comment