i hope you didn't type it down "as is" 'cus i just put it up there for illustration...
the real code would look something like this
function dist(obj1,obj2)
rem log object 1 coordinates
x1# = object position x(obj1)
y1# = object position y(obj1)
z1# = object position z(obj1)
rem log object 2 coordinates
x2# = object position x(obj2)
y2# = object position y(obj2)
z2# = object position z(obj2)
rem calculate distance
dist# = sqrt(sqr(x1#-x2#)+sqr(y1#-y2#)+sqr(z1#-z2#))
endfunction dist#
rem returns the square
function sqr(x#)
endfunction (x#*x#)
i think that should work, maybe some slight spelling errors or wrong command names but try it out. You should call the "dist" function with the object ID's of the two objects you want to find the distance between. Assign the result to a variable, so something like:
objdist# = dist(1,2)
that should store the distance between object 1 and 2 in the variable "objdist#". Try to understand what's actually going on rather than copying and pasting the code and seeing if it works or not, it helps the learning process