Page 2 of 2

Re: Moving FX Lights

Posted: April 24th, 2009, 12:42 am
by Nightmare
Drofder2004 wrote:small modification to the above...

Code: Select all

 
Firstly, remember this is an INFINITE LOOP, why would you want the engine to find the entity more than once if it isn't changing? Keep it outside the loop.

Secondly, Loops inside loops = infinite amounts of infinite loops.
Every time the loop went round, it created a NEW fx to play, after 1 minute passing you would have 6, eventually stacking to the point where your FPS would be shot and the server would crash.
What is it with people reading too fast these days?
The first script I posted is fine, the second one needs to be fixed, I agree, but you didn't follow the specifications I set in example 2.

Code: Select all

main()
{
	   maps\mp\_load::main();   //Load main functions
	   lightOrigin = getent ("fxOrigin","targetname");   //Assign the fxOrigin entity to lightOrigin
	   level._effect["light"] = loadfx ("fx/light/light.efx");  //Load myLight effect from myFxFolder
	   lightOrigin thread lightsMove();   //Run moving light thread while sending assigned lightOrigin
}

lightsMove(){    //Move lightOrigin back and forth along the X axis 64 units while looping continuously.
	trigger = getent ("lighttrigger","targetname");
	trigger waittill ("trigger");
	maps\mp\_fx::loopfx("light",lightOrigin.origin, 1); //Play loaded light effect at lightOrigin's origin every sec.
	while(1)
	{
	      wait(1);
	      self moveZ (-1000,1,0.5,0.5);
	      self waittill ("movedone");
	      wait(10);     
	      self moveZ (1000,1,0.5,0.5);
	      self waittill ("movedone");
         trigger waittill ("trigger");
	}
}
There.

Re: Moving FX Lights

Posted: April 24th, 2009, 2:10 pm
by Scorpion
Yup

Re: Moving FX Lights

Posted: April 24th, 2009, 7:42 pm
by Drofder2004
Sorry, I figured he wanted it to move once after being triggered, not loop forever after a trigger >.<