Using The Real 87's formula, ((abs(x1-x2)+abs(x2-x1))+(abs(z1-z2)+abs(z2-z1)+(abs(y1-y2)+abs(y2-y1)))
abs returns an absolute value, which really does nothing more than take a negative number and turn it into a positive, IF it is negative. The reason this is used is that you can't have a negative distance between two objects. Case in point, say that you are two feet from your monitor... What would negative two feet be?
abs(x1-x2) is the absolute value of the first x coordinate minus the second x coordinate. Thus, it is the difference between those two coords.
The rest are the same for x,y, and z respectively.
I'd do it a little bit different, though...
SELECT x1 > x2
CASE 1: a = x1-x2
CASE 0: a = x2-x1
ENDSELECT
SELECT y1 > y2
CASE 1: b = y1-y2
CASE 0: b = y2-y1
ENDSELECT
SELECT z1>z2
CASE 1: c = z1-z2
CASE 0: c = z2-z1
ENDSELECT
distance = a + b + c
...this way the processing time is cut down a little bit. ABS doesn't have to be used this way, and the program adapts to the situation.
This is all where x1 is the x position of the first object in the distance measurement, and x2 is the x position of the second.
The same applies for y1,y2,z1, and z2.
Become real good friends with math. You won't get very far with programming in any language if your brain says "NOPE!" any time you see it. Don't feel bad, though, as that is actually the natural human reaction to math. Only practice will reduce it, so to improve your skills, you gotta hunker down and grind out some math as practice until you know what you're seeing with a glance
You have a memory like trying to catch water in a steel trap. - A friend