Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Created by Gunnar Jessee 6/23/22
- -- Used for computertronics for computercraft
- local radar = peripheral.find("radar")
- local debug = false
- function findClosest()
- local players = {radar.getPlayers()}
- if debug then
- print(tostring(players))
- end
- local shortest = 1000000
- local name = ""
- for i = 1, #players[1] do
- dist = players[1][i].distance
- if dist < shortest then
- shortest = dist
- end
- end
- for i = 1, #players[1] do
- if players[1][i].distance == dist then
- name = players[1][i].name
- end
- end
- return name
- end
Add Comment
Please, Sign In to add comment