actualy widerbeast if you omit the sqrt from the equation it will speed up the calculation...but to keep it accurate just multiply the test distance by itself ...so rather than seeing if distance is less than 100 you would check the distance being < 10000
it takes a computer a long time to process the square root of a number.
using some algebra we can reduce the function down to this.
function object_distance(a,b)
l#= (object position z(a)-object position z(b))^2
w#= (object position x(a)-object position x(b))^2
h#= (object position y(a)-object position y(b))^2
d#= l#+w#+h#
endfunction d#
or in keeping with your structure
function object_distance(a,b)
d#=(object position x(a)-object position x(b))^2+(object position y(a)-object position y(b))^2+(object position z(a)-object position z(b))^2
endfunction d#
and like you had before for it\'s usage with 1 slight change
if object_distance(1,2)<(100^2) then print \"Object is in range\"
some other considerations you may want to add to the code would be the dimensions of the object too because this uses the objects centers so if the objects are over 100 units in size each they both would be overlapping before they are even read as being too close or in range.