Jump to content

TRYING TO ADD A LISTEN START & A KILL STOP TO A PARTICLE TEXTURE TIMER RANDOMIZER SCRIPT.


Pixels Sideways
 Share

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

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

Recommended Posts

HOLA!

I have an old Jopsy particle script that randomizes textures with a timer.  It's a cool  "teaching" script that allows you to learn about parameters of particles & change values so has a lot of extra stuff at the top.  I deleted the particle parameters edu annotations but left in ones for the main script functions.

I have modded it with the following objectives:

I added a listen event to start the particle process.

I added a kill stop particles line to stop the particle process.

The goal is when an avatar sits on an object, that object will tell the particle object to begin the randomizing texture particle process for 60 seconds then it stops until an avatar sits again..

I used a sleep to set it to run for 60 seconds then it should stop until it's called again to start via the listen.

It's not working.

How do I tweak this to get it to start via the listen then stop the particles after 60 seconds?

 

**  Ideally I would condense this so it's just the basic particle script and does not have it split with the input floats, integers, etc.  I tried that but the timer stuff is tied to the split particle stuff and could not clean it up and get it to work.

TY for your help.

pixels xoxo

==============================================================

 

// Jopsy's Particle System Template v5 - Jan 28 2005

//added listen


integer channel = -36367;

 

string       TEXTURE = "";

textureRandomise()
{
    integer textureNumber = llGetInventoryNumber(INVENTORY_TEXTURE);

    TEXTURE = llGetInventoryName(INVENTORY_TEXTURE, llFloor(llFrand(textureNumber)) );
}


 
mySetParticles()
{
    //===============================================================
    // Part-1 - APPEARANCE - Settings for how each particle LOOKS
    vector   START_SCALE = < 1.0,1.0,1.0 >; // < 1.0, 1.0, 0.0 >
    vector     END_SCALE = < 1.0,1.0,1.0 >; // < 1.0, 1.0, 0.0 >
    vector   START_COLOR = < 1.0, 1.0, 1.0 >; // < 1.0, 1.0, 1.0 >
    vector     END_COLOR = < 1.0, 1.0, 1.0 >; // < 1.0, 1.0, 1.0 >
    float    START_ALPHA = 1.0; // 1.00
    float      END_ALPHA = 1.0; // 1.00
    integer INTERP_COLOR = TRUE; // FALSE
    integer INTERP_SCALE = TRUE; // FALSE
    integer     EMISSIVE = TRUE; // FALSE
    float     AGE = 0.3; // 20.00
    float    RATE = 0.01;  // 0.1
    integer COUNT = 1;    // 3
    float    LIFE = 0.0;  // 0.0
    integer   PATTERN = PSYS_SRC_PATTERN_ANGLE; // PSYS_SRC_PATTERN_DROP
    float      RADIUS = 0.10; // 0.00
    float ANGLE_BEGIN = 0.10; // 0.00
    float   ANGLE_END = 0.00; // 0.00
    vector      OMEGA = < 0.00, 0.00, 1.00 >; // < 0.00, 0.00, 0.00 >
    integer      FOLLOW_SRC = FALSE; // FALSE
    integer FOLLOW_VELOCITY = FALSE; // FALSE
    integer            WIND = FALSE; // FALSE
    integer          BOUNCE = FALSE; // FALSE
    float         SPEED_MIN = 0.01; // 1.00
    float         SPEED_MAX = 0.01; // 1.00
    vector            ACCEL = < 0.00, 0.00, 0.10 >; // < 0.00, 0.00, 0.00 >
    integer      TARGET_POS = FALSE; // FALSE
    key              TARGET = llGetKey(); // llGetKey();

 

    list particle_parameters = [
            PSYS_PART_FLAGS, (
                (        EMISSIVE * PSYS_PART_EMISSIVE_MASK ) |
                (          BOUNCE * PSYS_PART_BOUNCE_MASK ) |
                (    INTERP_COLOR * PSYS_PART_INTERP_COLOR_MASK ) |
                (    INTERP_SCALE * PSYS_PART_INTERP_SCALE_MASK ) |
                (            WIND * PSYS_PART_WIND_MASK ) |
                (      FOLLOW_SRC * PSYS_PART_FOLLOW_SRC_MASK ) |
                ( FOLLOW_VELOCITY * PSYS_PART_FOLLOW_VELOCITY_MASK ) |
                (      TARGET_POS * PSYS_PART_TARGET_POS_MASK ) ),
            PSYS_PART_START_COLOR,     START_COLOR,
            PSYS_PART_END_COLOR,       END_COLOR,
            PSYS_PART_START_ALPHA,     START_ALPHA,
            PSYS_PART_END_ALPHA,       END_ALPHA,
            PSYS_PART_START_SCALE,     START_SCALE,
            PSYS_PART_END_SCALE,       END_SCALE,
            PSYS_SRC_PATTERN,          PATTERN,
            PSYS_SRC_BURST_PART_COUNT, COUNT,
            PSYS_SRC_BURST_RATE,       RATE,
            PSYS_PART_MAX_AGE,         AGE,
            PSYS_SRC_ACCEL,            ACCEL,
            PSYS_SRC_BURST_RADIUS,     RADIUS,
            PSYS_SRC_BURST_SPEED_MIN,  SPEED_MIN,
            PSYS_SRC_BURST_SPEED_MAX,  SPEED_MAX,
            PSYS_SRC_TARGET_KEY,       TARGET,
            PSYS_SRC_ANGLE_BEGIN,      ANGLE_BEGIN,
            PSYS_SRC_ANGLE_END,        ANGLE_END,
            //PSYS_SRC_INNERANGLE,       INNERANGLE,
            //PSYS_SRC_OUTERANGLE,       OUTERANGLE,
            PSYS_SRC_OMEGA,            OMEGA,
            PSYS_SRC_MAX_AGE,          LIFE,
            PSYS_SRC_TEXTURE,          TEXTURE
        ];
        
    llParticleSystem( particle_parameters ); // Turns on the particle hose!
        

}

default
{
    state_entry()

    
    {llParticleSystem([]);   //KILLS PARTICLES
    llSleep(2);  //GIVE IT A REST
         llListen( -33367, "", NULL_KEY, "" );  //LISTEN FOR STUFF
        mySetParticles();
        llSetTimerEvent(2); //changes particles texture every x seconds
    }
    
    timer()
    {
      textureRandomise();
      mySetParticles();
    }

    
    
listen( integer channel, string name, key id, string message )  //LISTEN FOR COMMAND
{
    if ( message == "mined" )  //LISTEN COMMAND TO START

{
        llParticleSystem([]); //turns off particles   // STOP
        llSleep(2);  //GIVE IT A REST

        mySetParticles(); // turn on the particles
        // llSetTimerEvent(60); // reset the alarm clock  //THIS IS TURNED OFF - NOT SURE HOW IT WORKS
        //play sound goes here
        llSleep(10);  //TEST TO SEE IF THIS WORKS & SHUTS OFF AFTER 10 SECONDS
        llParticleSystem([]); //turns off particles   // STOP
        //stop sound goes here
        
    }
}}

 

 

 

 

 

Edited by Pixels Sideways
addition
Link to comment
Share on other sites

While the script is stuck in the listen() event (sleeping until it stops the particles)  the timer() event can't fire until the listen() stops the particles and exits, and then timer() will just keep firing forever because there's nothing to tell it to stop.

It looks as if you tried to fix this by setting a 60 second timer, which would override the 2 second timer, but it's still the same timer() handler which would keep randomizing the particle textures forever,  but now on a 60 second cycle.

So we need a condition that will stop the particle-randomizing timer, and we need to observe that condition 60 seconds after the listen() happens. At that point we need to (1) stop the particles and (2) stop the timer, only starting again when a new message wakes up the listen() handler.

How to set up this timer-stopping condition without messing up the existing timer? In a simple case like this, I'd use a countdown mechanism so the timer can know to stop when a countdown variable, set to 30 in the listen(), decrements to 0 in the timer(). (30 decrements take 60 seconds in 2 second steps.)

There are other ways to handle multiple scheduled events in a single script. Another trick is to use a second timer-like event: the no_sensor event triggered by an impossible llSensorRepeat. Or stick with a single timer() and have it manage a whole scheduled queue of work. I think the countdown is the simplest form of that work queue.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 321 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...