Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Easier way to have an event turn on then off after a set amount of time?

Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
11-03-2005 20:00
I'm working on a script which is supposed to turn a particle effect on when a command is given and then automatically turn it off 10 seconds later. right now it "works" but the code is very "Sloppy" as I'm using a timer command with the "on" command to turn it off every 6 seconds automatically. obviously there are some bugs with this, as if you give the on command 1 second before the off comand is given through the timer script, the off command will be given too soon. I was thinking of using the llSleep command, but I'm not too sure of it's intended use and how much it would screw up my script.
RacerX Gullwing
Magic Rabbit
Join date: 18 Jun 2004
Posts: 371
11-03-2005 20:49
add a sleep its simple, and uses much less recources than turning something off every 6 secondes
llSleep(6);
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
11-03-2005 20:54
thanks. cleaned up my script a lot.


would it be possible to use the llsleep command to delete a prim a certain amount of time after it's spawned and not have it interfere with any other parts of the script? or would I have to have 2 seperate scripts in the prim that gets summoned?
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
11-04-2005 00:27
An llSleep command--per my understanding--actually pauses the script while it sleeps...so it would interfere with any further processing by the same script.
_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
Ben Bacon
Registered User
Join date: 14 Jul 2005
Posts: 809
11-04-2005 02:53
Senuka - only start the timer when you start the particles.
CODE
default
{
touch_start(integer num_detected)
{
llParticleSystem([............................]);
llSetTimerEvent(10.0); //(re)start the timer
}

timer()
{
llParticleSystem([]);
timer(0.0); // stop the timer again
}
}

As Kenn says, llSleep pauses the script completely, so prefer the timer most of the time.
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
11-05-2005 13:09
From: Ben Bacon
Senuka - only start the timer when you start the particles.
As Kenn says, llSleep pauses the script completely, so prefer the timer most of the time.


ah thanks. I thought that if I were to set the timer to 0, it would cause a contstant loop of that event, furthuring to "lag" from excessive scripts
Drake Diamond
Registered User
Join date: 4 Apr 2005
Posts: 1
11-05-2005 19:47
you can also use the "system life" variable in the particle function.
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
11-06-2005 01:26
Setting the timer to 0 is how you turn it off.