
This Roll20 API script is to detect nearest token when a token is moved. Right now this works but just logs the nearest token (by name). Will be improving on the idea in the future to include N nearest tokens and other variations.
Uses a KDTree implementation attributed in the source.
Note: For equidistant tokens this will choose the north closest token first. KDTree implementation would need to be changed to return a set of more than 1 "closest" with multiple equidistant tokens