Can you pass an entity pointer to a function?

Posted By: WildCat

Can you pass an entity pointer to a function? - 07/25/02 12:06

I know functions can take in parameters... can one of those parameters be an entity pointer like YOU, or must you convert it to a handle, pass the handle and then convert it back to the pointer in the function?

(If that makes any sense)

- WildCat
Posted By: mudhole

Re: Can you pass an entity pointer to a function? - 07/25/02 13:22

This isn't more about ptr_for_handle(...) == NULL is it?

JCL told you that code wouldnt work!!

I posted a possible solution in the previous thread.
http://www.conitecserver.com/ubb/ultimatebb.php?ubb=get_topic;f=15;t=002050

In answer to your question, yes you can. But you must assign the parameter to a script defined pointer of known type before you can use it directly for assignments.

eg.

code:
entity* myEnt;
....
// call the function
SomeFunction(me);
....
function SomeFunction(entPtr)
{
// can't use entPtr directly, so assign it to an already defined pointer
myEnt = entPtr;

// now use myEnt to assign values to entPtr
myEnt.passable = on;
}
....


Posted By: WildCat

Re: Can you pass an entity pointer to a function? - 07/25/02 20:18

Hi Mudhole,
I should yell at you for making an assumption about what I need this for, but I won't.

This has nothing to do with the NULL issue. I've long since delt with that.

This is for an advanced collision detection system using WDL.

Thanks for the input. Your answer was exactly what I was looking for.

- WildCat
© 2024 lite-C Forums