Passing entitys directly

Blitz3D Forums/Blitz3D Programming/Passing entitys directly

PaulJG(Posted 2004) [#1]
Can some kind person please shed some light on this lil problem for me.

I'm trying to pass a handle of an object into a function, seems to work as long as the object isnt a CHILD of an object.

Here's what I'm doing:

loading 'body' as parent object
loading 'head' as child of body object

passing the handle of the object into a function

disp(body)
disp(head)

..

function disp(temp_handle#)
..
positionentity temp_handle#,1,1,1
..
end function


Works fine for body, but I get an error of 'entity does not exist' for the head. I think as its a child object, its not sending the correct pointer to the routine ?.


Ross C(Posted 2004) [#2]
Are both handles made global?


PaulJG(Posted 2004) [#3]
yes.. they are now. [ whoops ]

didnt make any difference though..

Like I said, if I take out the call to the function for 'head' - the body works fine. Is it something to do with the way blitz stores child objects ? - are they somehow attached to the main handle as an offset ?? (so it's not passing the correct pointer)


fredborg(Posted 2004) [#4]
Don't use floats for handles.


PaulJG(Posted 2004) [#5]
got around the problem by making the second object a normal object. (parent)

So I guess the error is something to do with it being a child - anyway thanks for the suggestions.


Who was John Galt?(Posted 2004) [#6]
try putting a global flag on the positionentity


N(Posted 2004) [#7]
And, like Fredborg said, don't use a float. No reason to use a float when all entity handles are integers.


fredborg(Posted 2004) [#8]
No reason to use a float when all entity handles are integers.
Especially because they are bound to cause Memory Access Violations, as they don't have the same numeric span and/or precision as integers.