what's a dangerous instruction??

Posted By: ello

what's a dangerous instruction?? - 02/05/10 20:24

hi there,

i am getting a malfuntion 1511 : Dangerous instruction in event soundso

whats that??

this is the code its refering to
Code:
void stern_spray()
{
	set(me,PASSABLE|TRANSLUCENT|ZNEAR|BRIGHT);
//	if (random(10)>7) set(me,BRIGHT);
	my.alpha = random(50)+50;
	my.x += random(64)-32;
	my.y += random(64)-32;
	my.z += random(64)-32;
	vec_scale(my.scale_x,0.01 + random(10)/33);
	my.roll=random(360);
	var xspeed = random(23) - 11.5, yspeed = random(23) - 11.5, zspeed = random(23) - 11.5, rollspeed = random(14)-7;
	while(my.alpha>0)
	{
		my.alpha -= 5*time_step;
		my.roll += rollspeed;
		c_move(me,nullvector,vector(xspeed,yspeed,zspeed),IGNORE_PASSABLE|IGNORE_SPRITES);
		zspeed -= time_step;
		wait(1);
	}
	ent_remove(me);
}


Posted By: Superku

Re: what's a dangerous instruction?? - 02/05/10 22:41

[EDIT] [...] Is stern_spray an event function?

Manual:

Warning W1511 - dangerous instruction in event
Die angegebene Event-Funktion enthält eine verbotene Anweisung (siehe "Event-Fallen"). Anweisungen, die etwas im Level ändern oder selbst Events auslösen können, wie c_move, ptr_remove, ent_create, c_trace, c_scan, video_switch etc. dürfen nicht im ersten Zyklus eines Events ausgeführt werden. Fügen Sie vor dem Ausführen solcher Anweisungen in einer Event-Funktion ein wait(1) ein. Diese Meldung wird bei einem warn_level von 2 oder höher ausgegeben.
Posted By: ello

Re: what's a dangerous instruction?? - 02/06/10 00:34

not directly.. its the function of an entity created within an event
Posted By: Joozey

Re: what's a dangerous instruction?? - 02/06/10 02:57

And if you remove the wait it doesn't throw an error?
Posted By: Xarthor

Re: what's a dangerous instruction?? - 02/06/10 07:31

Did you use a wait(1) instruction before creating the entity in the event function?
Posted By: FBL

Re: what's a dangerous instruction?? - 02/06/10 10:17

You need a wait(1) before doing c_move. Put it before the while loop starts.

Otherwise the event creates an entity with a function which calls an engine function which can trigger an event right away which *COULD* in theory trigger the first event again and thus end up in an endless loop.
© 2024 lite-C Forums