Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- load the API
- os.loadAPI("ocs/apis/sensor")
- -- the location of the door relative to the sensor
- local offset = {
- X = 1,
- Y = 1,
- Z = 0
- }
- local radius = 3
- -- find the distance from the player position to the offset
- function distance(pos)
- local xd = pos.X - offset.X
- local yd = pos.Y - offset.Y
- local zd = pos.Z - offset.Z
- return math.sqrt(xd*xd + yd*yd + zd*zd)
- end
- -- wrap the sensor
- prox = sensor.wrap("left")
- -- get the targets
- while true do
- local signal = true
- local targets = prox.getTargets()
- -- loop through them
- for name, v in pairs(targets) do
- -- get more details about them
- local moreDetails = prox.getTargetDetails(name)
- if distance(v.Position) < radius and name == "Yourname" then signal = false
- end
- end
- rs.setOutput("top", signal)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement