Swimmie Chaffe Posted April 11, 2011 Share Posted April 11, 2011 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 textureslist 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 More sharing options...
Darkie Minotaur Posted April 11, 2011 Share Posted April 11, 2011 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 More sharing options...
Swimmie Chaffe Posted April 11, 2011 Author Share Posted April 11, 2011 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 More sharing options...
Swimmie Chaffe Posted April 11, 2011 Author Share Posted April 11, 2011 P.S... >>Further more, don't use "" here: PSYS_SRC_TEXTURE, (key)"random_texture". What would you suggest me to use here instead? Link to comment Share on other sites More sharing options...
Darkie Minotaur Posted April 11, 2011 Share Posted April 11, 2011 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 1 Link to comment Share on other sites More sharing options...
Swimmie Chaffe Posted April 11, 2011 Author Share Posted April 11, 2011 It worked ! Thank you very much, Darkie! Link to comment Share on other sites More sharing options...
Guest Posted July 20, 2014 Share Posted July 20, 2014 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 More sharing options...
KarlosBabini Posted August 25 Share Posted August 25 (edited) Thank you for the post, with the help of all of you, I managed to use two textures by UUID, Ty Swimmie Chaffe and Darkie Minotaur. ParticleSystem Breath of Fire and Smoke for dragon integer pattern = PSYS_SRC_PATTERN_ANGLE_CONE; // Particle Variables. float maxsysage = 0.6; float maxspeed = 2.35; float minspeed = 0.35; float burstrad = 0.0; integer burstcount = 1; float burstrate = 0.035; float outangle = 1.0; float inangle = 1.0; vector omega = <0.0,0.0,0.0>; vector startcol = <1.0, 1.0, 1.0>; vector endcol = <1.0, 1.0, 1.0>; float startalph = 0.25; float endalph = 0.000; vector startscale = <0.02,0.02,0.1>; vector endscale = <0.5,0.5,0.25>; float maxage = 1.5; vector accel = <0.0, 0.0, 0.1>; //string texture = "BigExplosion1"; string random_texture = ""; //A set of textures list textures = [ "5e47a0dc-97bf-44e0-8b40-de06718cee9d",//BigExplosion1 "351f44e5-69c3-08f8-c3a7-54ca14e59290"//goo ]; // Script variables integer flags; /* updateParticles() { flags = 0; flags = flags | PSYS_PART_INTERP_COLOR_MASK; flags = flags | PSYS_PART_INTERP_SCALE_MASK; flags = flags | PSYS_PART_WIND_MASK; */ integer status = 1; integer cooldown = 0; string animation; breath_out() { llParticleSystem([]); vector vel = llGetVel(); if (llGetAnimation(llGetOwner()) == "Sitting") { vel = ZERO_VECTOR; } inangle = 0.3 + (0.7 * (llVecMag(vel) / 3.0)); if (inangle > 1.0) inangle = 1.0; maxspeed = 0.5 + (0.5 *(llVecMag(vel) / 3.0)); if (maxspeed > 1.0) maxspeed = 1.0; minspeed = maxspeed * 0.8; llParticleSystem([ PSYS_PART_FLAGS, PSYS_PART_INTERP_COLOR_MASK | PSYS_PART_INTERP_SCALE_MASK | PSYS_PART_FOLLOW_SRC_MASK | PSYS_PART_FOLLOW_VELOCITY_MASK | PSYS_PART_WIND_MASK, PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_ANGLE_CONE, PSYS_PART_START_COLOR, startcol, PSYS_PART_START_ALPHA, startalph, PSYS_PART_END_COLOR, endcol, PSYS_PART_END_ALPHA, endalph, PSYS_PART_START_SCALE, startscale, PSYS_PART_END_SCALE, endscale, PSYS_PART_MAX_AGE, maxage, PSYS_SRC_ACCEL, (vel * -0.85) + <0.0, 0.0, 0.2>, PSYS_SRC_TEXTURE, (key)random_texture, PSYS_SRC_BURST_RATE, burstrate, PSYS_SRC_ANGLE_BEGIN, inangle, PSYS_SRC_ANGLE_END, inangle, PSYS_SRC_BURST_PART_COUNT, burstcount, PSYS_SRC_BURST_RADIUS, burstrad, PSYS_SRC_BURST_SPEED_MIN, minspeed, PSYS_SRC_BURST_SPEED_MAX, maxspeed, PSYS_SRC_MAX_AGE, maxsysage, PSYS_SRC_OMEGA, omega ]); } hold_breath() { llParticleSystem([ PSYS_PART_FLAGS, PSYS_PART_INTERP_COLOR_MASK | PSYS_PART_INTERP_SCALE_MASK | PSYS_PART_FOLLOW_SRC_MASK | PSYS_PART_FOLLOW_VELOCITY_MASK, PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_EXPLODE, PSYS_PART_START_COLOR, startcol, PSYS_PART_START_ALPHA, startalph, PSYS_PART_END_COLOR, endcol, PSYS_PART_END_ALPHA, endalph, PSYS_PART_START_SCALE, startscale, PSYS_PART_END_SCALE, endscale, PSYS_PART_MAX_AGE, maxage, PSYS_SRC_ACCEL, accel, PSYS_SRC_TEXTURE, (key)random_texture, PSYS_SRC_BURST_RATE, burstrate, PSYS_SRC_INNERANGLE, inangle, PSYS_SRC_OUTERANGLE, outangle, PSYS_SRC_BURST_PART_COUNT, burstcount, PSYS_SRC_BURST_RADIUS, burstrad, PSYS_SRC_BURST_SPEED_MIN, minspeed, PSYS_SRC_BURST_SPEED_MAX, maxspeed, PSYS_SRC_MAX_AGE, 0.01, PSYS_SRC_OMEGA, omega ]); llParticleSystem([]); } default { state_entry() { vector vel = llGetVel(); breath_out(); //updateParticles(); llSetTimerEvent(4); } 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); breath_out(); } } Edited August 25 by KarlosBabini Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now