Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("ocs/apis/sensor")
- -- the location of the redstone lamp relative to the sensor
- local offset = {
- X = 1,
- Y = 1,
- Z = 0
- }
- -- how close a player has to be to activate the lamp
- local radius = 5
- -- 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
- local prox = sensor.wrap("top")
- while true do
- local signal = false
- local targets = prox.getTargets()
- for k, v in pairs(targets) do
- if distance(v.Position) < radius then
- signal = true
- print(k)
- sleep(1)
- term.clear()
- -- print(k)
- term.setCursorPos(1,1)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement