Hi,

I've just created a piece of code that works. But the manual says that it's not a good idea.
Quote:
The event function itself should be simple. It normally should only transfer information to the entities' main function - it shouldn't perform instructions that can trigger events itself, displace entities, start particles or change anything else in the level. Thus instructions like c_move, ent_create, ptr_remove, c_trace etc. must not be performed. If the event function must perform such 'critical instructions', precede them by a wait(1) for delaying them to the next frame. Then it's safe.


In the event function I'm using a while loop, particles and ptr_remove. My idea is I'm only calling the event function 1 time, and not every frame therefore there shouldn't be any problem, right?? Imo cause I'm setting the passble and the invisible the event function turns into a normal function. But I'm really not sure at all. Could some1 correct me or agree?

Code:

Code:
function rocket_handle()
{
	set(my, PASSABLE | INVISIBLE);
	var exposion_time = 0;
	while(exposion_time < 5)
	{
		// call function destroy_rocket each frame, generating 3 particle at the position of the entity (my.x)
	   effect(destroy_rocket, 3, my.x, nullvector);
	   exposion_time +=1;
	   
	   wait(1);	
	}
	
	ptr_remove(me);
}

function enemy_rocket_movement()
{
	my.emask |= (ENABLE_BLOCK | ENABLE_ENTITY); // Makes entity sensitive for block and entity collision
   my.event = rocket_handle;
	
	while(1)
	{
		c_move(my,vector(30*time_step,0,0),nullvector,IGNORE_PASSABLE | GLIDE | IGNORE_FLAG2 | ACTIVATE_PUSH); //moves the rocket
		wait(1);
	}
}




The more you have.. the more you can lose...
Dont tell em all you know.....