Jump to content

how to stop llSetLinkPrimitiveParamsFast inside a timer?


dk201
 Share

You are about to reply to a thread that has been inactive for 2518 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hello Everyone, I am playing around following script to create laser effect. Everything works great except that I cannot stop it. lol

I have tried regular ways to stop Particle and Primitive mentioned in this link: http://wiki.secondlife.com/wiki/LlSetPrimitiveParams

I think maybe the timer cause this primitive keep displaying. But I have already deleted following script from my item, the laser effect still there. How can I get rid of this laser effect?

Appreciated your help.

 

default
{
state_entry()
{
llLinkParticleSystem(2, [0, 307, 7, .25, 1, <1,0,0>, 3, <1,0,0>, 5, <.04,.25,0>, 6, <.04,.25,0>, 9, 2, 13, .01, 8, <0,0,0>, 15, 10, 16, .01, 17, 0, 18, 2., 10, 8., 11, 0., 21, <0,0,0>, 19, 0., 12, "", 2, .7, 4, 0.]);
llSetTimerEvent(0.05);
}

timer()
{
float distance = llVecDist(llGetPos(), llList2Vector(llCastRay(llGetPos(), llGetPos() + (llRot2Fwd(llGetRot())*32.0), [RC_MAX_HITS, 1]), 1));
if(distance > 32) distance = 32;
llSetLinkPrimitiveParamsFast(2, [PRIM_SIZE, <0, 0, distance*2>, PRIM_POSITION, <distance, 0, 0>]);
}
}

Link to comment
Share on other sites

Particles are a prim property, like hover text and many other properties.  They require a script to start or stop them, but not to maintain them.  Once you start particles, you can remove the script that created them -- unless you plan to stop the particles again.

To stop particles, you just need to write

llParticleSystem([]);

In your case, that's all you need in a very simple script. Put it in state_entry, drop it in the script, and "poof!"

BTW, if you ever decide to use that old scipt again, I really recommend slowing the timer down.  There's no need to run a timer that fast in a script like this.

Link to comment
Share on other sites

To turn off the particles, you need to call 

llLinkParticleSystem(LINK_SET,[]);

To stop a timer, you need to call llSetTimerEvent (0.0);

I don't really understand what the script's trying to do -- I can see what it actually does do, but I can't quite see what you wanted it to do.

Would this sort of logic help?

integer toggle; //toggle starts off as falsefloat fInterval = 0.1;default{	state_entry()	{			}	touch_start(integer total_number)	{		if(toggle=!toggle){//shorthand for "switch the value of toggle and, if that makes toggle true..."			llSetTimerEvent(fInterval); //start the timer			llLinkParticleSystem({some parameters});//start the particles		}		else{  // if switching the value of toggle makes it false			llSetTimerEvent(0.0);//turn off the timer			llLinkParticleSystem(LINK_SET,[]); //turn off the particles		}	}	timer()	{		//do stuff 	}}

 

 

Link to comment
Share on other sites

Further questions: I started a timer in script A, and then i deleted script A. Would timer still running? and, if yes, can i turn off it by adding a new script and use llSetTimerEvent(0,0)? How does server know which timer i want to turn off?

 

Link to comment
Share on other sites

No, once you deleted the script, that would stop the timer.

I think what has happened is you're still seeing the particles.   That's expected behaviour -- particles are a prim property, same as colour or size or texture.   You set the particles with a script, but then you can delete the script and the particles will keep on going.

To turn off all particles in your linkset,  simply drop this script into the root prim:

default{	state_entry()	{		llLinkParticleSystem(LINK_SET,[]);		llRemoveInventory(llGetScriptName());	}}
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2518 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...