Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = peripheral.find("playerDetector")
- local chat = peripheral.find("chatBox")
- function binarySearch(a, b)
- if b - a == 1 then
- local players = player.getPlayersInCubic(a, a, a)
- if #players == 0 then
- return b, player.getPlayersInCubic(b, b, b)
- else
- return a, players
- end
- end
- local m = math.ceil((a + b) / 2)
- local count = #player.getPlayersInCubic(m, m, m)
- if count == 0 then
- return binarySearch(m, b)
- else
- return binarySearch(a, m)
- end
- end
- function binarySearchX(a, b, yz, p)
- if b - a == 1 then
- return player.isPlayerInCubic(a, yz, yz, p) and a or b
- end
- local m = math.ceil((a + b) / 2)
- if player.isPlayerInCubic(m, yz, yz, p) then
- return binarySearchX(a, m, yz, p)
- else
- return binarySearchX(m, b, yz, p)
- end
- end
- function binarySearchY(a, b, x, yz, p)
- if b - a == 1 then
- return player.isPlayerInCubic(x, a, yz, p) and a or b
- end
- local m = math.ceil((a + b) / 2)
- if player.isPlayerInCubic(x, m, yz, p) then
- return binarySearchY(a, m, x, yz, p)
- else
- return binarySearchY(m, b, x, yz, p)
- end
- end
- function binarySearchZ(a, b, x, y, p)
- if b - a == 1 then
- return player.isPlayerInCubic(x, y, a, p) and a or b
- end
- local m = math.ceil((a + b) / 2)
- if player.isPlayerInCubic(x, y, m, p) then
- return binarySearchZ(a, m, x, y, p)
- else
- return binarySearchZ(m, b, x, y, p)
- end
- end
- while true do
- -- local br = 1
- -- while #player.getPlayersInCubic(br, br, br) == 0 do
- -- br = br * 2
- -- if br == 256 then
- -- break
- -- end
- -- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement