I know that you can't use variables that aren't global in functions. I know how to pass data into it also. I also know how to make and use functions. This is the code that won't work.
FUNCTION AI_travel(bot#,x#,y#,z#,distance#,speed#)
`store the bot's current position
botX# = OBJECT POSITION X(bot#)
botY# = OBJECT POSITION Y(bot#)
botZ# = OBJECT POSITION Z(bot#)
`calculate the distance between the bot and the new location to travel to
botDist# = math_getDist3D(int(botX#),int(botY#),int(botZ#),int(x#),int(y#),int(z#))
`if the bot is less than the specified allowed distance away,
`make the bot face the new location and move forward
IF botDist# > distance#
POINT OBJECT bot#,x#,y#,z#
MOVE OBJECT bot#,speed#
ELSE
`If the task is completed, return a 1 signifying completion.
complete = 1
ENDIF
ENDFUNCTION complete
FUNCTION math_getDist3D(X1#,Y1#,Z1#,X2#,Y2#,Z2#)
SET VECTOR3 vecDist3D,X1#-X2#,Y1#-Y2#,Z1#-Z2#
dist = LENGTH VECTOR3(vecDist3D)
ENDFUNCTION int(dist)
Now, if I change it to
FUNCTION math_getDist3D(X1#,Y1#,Z1#,X2#,Y2#,Z2#)
SET VECTOR3 vecDist3D,X1#-X2#,Y1#-Y2#,Z1#-Z2#
dist = LENGTH VECTOR3(vecDist3D)
ENDFUNCTION int(dist)
FUNCTION AI_travel(bot#,x#,y#,z#,distance#,speed#)
`store the bot's current position
botX# = OBJECT POSITION X(bot#)
botY# = OBJECT POSITION Y(bot#)
botZ# = OBJECT POSITION Z(bot#)
`calculate the distance between the bot and the new location to travel to
botDist# = math_getDist3D(int(botX#),int(botY#),int(botZ#),int(x#),int(y#),int(z#))
`if the bot is less than the specified allowed distance away,
`make the bot face the new location and move forward
IF botDist# > distance#
POINT OBJECT bot#,x#,y#,z#
MOVE OBJECT bot#,speed#
ELSE
`If the task is completed, return a 1 signifying completion.
complete = 1
ENDIF
ENDFUNCTION complete
it will work when I call AI_Travel.