Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Range = 255
- local sensor = peripheral.wrap("top")
- local whitelist =
- {
- "YOUR_IGN"
- }
- detected = 0
- rs.setOutput("front",false)
- whitelistcheck = {}
- for index, value in pairs(whitelist) do
- whitelistcheck[value] = "Team"
- end
- rs.setOutput("front",false)
- local function sense()
- while true do
- detected = 0
- for Key, Value in pairs(sensor.sense()) do
- local Meta = sensor.getMetaByID(Value.id)
- if not Meta or not Meta.food then
- else
- local Distance = math.sqrt(Meta.x * Meta.x + Meta.y * Meta.y + Meta.z * Meta.z)
- if (whitelistcheck[Meta.name] == nil and
- Distance < Range) then
- detected = 1
- local Name = Meta.displayName
- --player is detected do something
- rs.setOutput("front",true)
- print(Name)
- end
- end
- end
- if detected == 0 then
- --player is not detected
- rs.setOutput("front",false)
- end
- os.sleep(0.10)
- end
- end
- sense()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement