Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / can't use the variable the function made

Author
Message
aks74u
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: arizona
Posted: 2nd Jul 2004 15:41
if object position x(104) dist > 250 then move object 104,2

i have a function that finds distance between two objects. it says "cannot determine parameter type" on that line. dist is my variable. i made it global but i dont no if that does anything. is there a certain way to call a variable from a function?
thx for you r help

mulletman47@aol.com
aks74u
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: arizona
Posted: 2nd Jul 2004 16:41
i fixed it by using

if dist# > 100 then move object 104,2

but now it says cannot difine a function inside another function at line 246

here s line 246

function dist()


i dont understannd. when i put sutff inside the parentheses it says the same thing.

help plz

mulletman47@aol.com
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 2nd Jul 2004 18:39
Well, the "object position X()" is a value all by itself, so I (and the compiler) have no idea how it relates to your "dist" tag. Even if define the object using the type command of object.dist as integer the "object position x()" would be the location of the object without regard to the "object.dist" value.

in other words; Object position x() is a number returned by direct-x itself -- ie; where is this object in the 3D space? The .dist value is that local number you use to locate the object, not where direct-x thinks it is. (big difference there.)

As for the function of dist() versus the variable of dist#, dist# may or may not be global but the function dist() is always global. Dist() is a called operation, ie; do the code after the function declaration and possibly return a value from it. Dist# is a variable, which can be global dist# or it can be local if used in a function as dist(dist#, x, y).

If that has not confused the heck out of you I'd suggest you don't make functions with the same name as your variables, for the very reason above.

But basically, you are not finding the object position correctly in your if statement, the .dist extension has nothing to do with the object position x() command.

s.

Any truly great code should be indisguishable from magic.
aks74u
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: arizona
Posted: 3rd Jul 2004 05:53
ok now i got it i fixed it all thx so muc sandrad for helping me here and everywhere else!!i was calling function dist() in the loop when i shouldve used just dist()

mulletman47@aol.com

Login to post a reply

Server time is: 2024-09-22 15:33:03
Your offset time is: 2024-09-22 15:33:03