Jump to content

Simple particle script with an texture randomizing effect


Swimmie Chaffe
 Share

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

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

Recommended Posts

Hi,

I am trying to write a particle script with random textures (with a UUID list, not textures in the prim inventory) in the simplist way. This is my attempt, but my script is not picking up textures :-(

I'd appreciate if anyone could help identifying and fixing errors in this script. Thanks in advance for your help!

P.S. Is it possible to randomize textures without using timer? If so, how?


//A set of textures
list textures =
[
"ad90ac58-6e23-afbc-1f4f-6adbfd78b5b5",
"dcab6cc4-172f-e30d-b1d0-f558446f20d4",
"bb08ed92-9f0e-85d8-2eaf-9f67b7795e3d"

];

default
{
    state_entry()
    {
 //Randomize Textures       
        integer number_of_textures = llGetListLength(textures);
        integer random_texture_index = (integer) llFrand(number_of_textures);
        string random_texture = "";
        random_texture = llList2String(textures, random_texture_index);
        
          
        llSetTimerEvent(0.1);
      
    }

    timer()
    {

//Start Particle        
         llParticleSystem([
             PSYS_PART_FLAGS , 0  | PSYS_PART_INTERP_COLOR_MASK | PSYS_PART_INTERP_SCALE_MASK | PSYS_PART_FOLLOW_VELOCITY_MASK | PSYS_PART_EMISSIVE_MASK,
             PSYS_SRC_PATTERN, 8, PSYS_SRC_TEXTURE, (key)"random_texture",
             PSYS_SRC_MAX_AGE, 0.000000,
             PSYS_PART_MAX_AGE, 1.000000,
             PSYS_SRC_BURST_RATE, 0.010000,
             PSYS_SRC_BURST_PART_COUNT, 4,
             PSYS_SRC_BURST_RADIUS, 2.000000,
             PSYS_SRC_ACCEL, <0.00000, 0.00000, 0.00000>,
             PSYS_SRC_BURST_SPEED_MIN, 1.000000,
             PSYS_SRC_BURST_SPEED_MAX, 0.000000,
             PSYS_PART_START_COLOR, <1.00000, 1.00000, 1.00000>,
             PSYS_PART_END_COLOR, <1.00000, 1.00000, 1.00000>,
             PSYS_PART_START_ALPHA, 0.000000,
             PSYS_PART_END_ALPHA, 1.000000,
             PSYS_PART_START_SCALE, <0.5, 0.5, 0.5>,
             PSYS_PART_END_SCALE, <0.5, 0.5, 0.5>,
             PSYS_SRC_ANGLE_BEGIN, 1.625000,
             PSYS_SRC_ANGLE_END, 1.625000,
             PSYS_SRC_OMEGA, <0.00000, 0.00000, 0.00000>]);
    }
    
}

 

 

Link to comment
Share on other sites

You do the randomization in the start_entry event only - that meanss, you do it just once. You have to move this part into the timer event, too. And don't use 0.1 seconds - tzhat's way too fast.

Further more, don't use "" here: PSYS_SRC_TEXTURE, (key)"random_texture".

I hope I've seen all that is needed to run it. There are some optimazations that could be done, too (I'm sure there will be some amount of advice comming).

As far as the event is concerned: You could use almost any event - it all depends on the effect you want. You could randomly change on a collision, on a touch, on a chat command ... If you want it time driven without a timer, you could

  • define a jump target just in front of the randomization
  • add llSleep() after the llParticleSystem
  • after the sleep, jump to the jump target
Link to comment
Share on other sites

Hi Darkie,

Thanks for your prompt reply and willingness to help. I can see my script contains multiple issues (errors + wasteful codes), but I am still not sure how I can fix my script so that it would randomly pick a texture from the list. I moved the entire ramdomization effect part under "timer", but the script is still not picking up textures...

Any suggestions?

Swimmie

Link to comment
Share on other sites

Try this - I can't go in-world right now

 

//A set of textureslist textures =["ad90ac58-6e23-afbc-1f4f-6adbfd78b5b5","dcab6cc4-172f-e30d-b1d0-f558446f20d4","bb08ed92-9f0e-85d8-2eaf-9f67b7795e3d"];default{    state_entry()    { //Randomize Textures                          llSetTimerEvent(5);          }    timer()    {	    integer number_of_textures = llGetListLength(textures);        integer random_texture_index = (integer) llFrand(number_of_textures);        string random_texture = "";        random_texture = llList2String(textures, random_texture_index);                 //Start Particle                 llParticleSystem([             PSYS_PART_FLAGS , 0  | PSYS_PART_INTERP_COLOR_MASK | PSYS_PART_INTERP_SCALE_MASK | PSYS_PART_FOLLOW_VELOCITY_MASK | 	     PSYS_PART_EMISSIVE_MASK,             PSYS_SRC_PATTERN, 8, PSYS_SRC_TEXTURE, (key)random_texture,             PSYS_SRC_MAX_AGE, 0.000000,             PSYS_PART_MAX_AGE, 1.000000,             PSYS_SRC_BURST_RATE, 0.010000,             PSYS_SRC_BURST_PART_COUNT, 4,             PSYS_SRC_BURST_RADIUS, 2.000000,             PSYS_SRC_ACCEL, <0.00000, 0.00000, 0.00000>,             PSYS_SRC_BURST_SPEED_MIN, 1.000000,             PSYS_SRC_BURST_SPEED_MAX, 0.000000,             PSYS_PART_START_COLOR, <1.00000, 1.00000, 1.00000>,             PSYS_PART_END_COLOR, <1.00000, 1.00000, 1.00000>,             PSYS_PART_START_ALPHA, 0.000000,             PSYS_PART_END_ALPHA, 1.000000,             PSYS_PART_START_SCALE, <0.5, 0.5, 0.5>,             PSYS_PART_END_SCALE, <0.5, 0.5, 0.5>,             PSYS_SRC_ANGLE_BEGIN, 1.625000,             PSYS_SRC_ANGLE_END, 1.625000,             PSYS_SRC_OMEGA, <0.00000, 0.00000, 0.00000>]);    }    }

 

You just put the variable name 

 

random_texture
  • Like 1
Link to comment
Share on other sites

  • 3 years later...

Darkie, I found this script and it's pretty neat :matte-motes-bashful-cute: What if one wanted to randomize the size, timing  and/or distance of the particles in a script? Thanks : )i( :

Link to comment
Share on other sites

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