About on_ent_remove

Posted By: 3run

About on_ent_remove - 11/01/18 14:23

Hi!

I just wanted to ask about - on_ent_remove (manual isn't really clear enough about it). Let's say I have something like this:
Code:
action test_dummy(){
	
	on_ent_remove = remove_dummy;
	
	while(my){
		
		wait(1);
		
	}
	
}

Will this set 'remove_dummy' only for this entity (test_dummy), OR will it call it for all entities before deleting them? If by that single line I set 'remove_dummy' for all removing entities, this will mess all other on_ent_remove function set by the engine (f.e. physX) right? I'm a bit confused. Is there a function/event to be set for a specific entity, without messing other stuff?

Best regards!
Posted By: WretchedSid

Re: About on_ent_remove - 11/01/18 14:45

The manual reads like it gets called for every entity, I guess you could tag yours with a specific skill to figure out when you want to run a certain action.

To chain them, just take the pointer of the previous function and run it inside of yours, something like this:

Code:
function (*prev_ent_remove)(ENTITY *); 

function my_ent_remove(ENTITY *ent)
{
   // ...

   if(prev_ent_remove)
       prev_ent_remove();
}


void main()
{
    prev_ent_remove = ent_remove;
    ent_remove = my_ent_remove;
}



(No guarantee that this will run like this in Lite-C cuz Lite-C is weird af, but you get the idea)
Posted By: 3run

Re: About on_ent_remove - 11/01/18 15:25

Hey, that sounds like a good workaround. Thank you!
© 2024 lite-C Forums