Particle Positioning-Garden

Thread Started By deadpool

2346
0
  • 32 Vote(s) - 2.69 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rate Thread
#1
What is it?

A particle emitter created by Jopsy Pendragon, later edited by Joris Tolsen, set to work as a square style particle garden. Since parcels / properties in Second Life don’t have curved edges, this creation is great for utilizing every sqm. Check the commands in script or follow the help prompt when first saving the script.

How-to/Info:

•Copy paste the script below into a new script inworld.
•Save it & then put the script into an object (if not there already).

PHP Code:
//// "Fire" PARTICLE TEMPLATE v1 - by Jopsy Pendragon - 4/8/2008
//// You are free to use this script as you please, so long as you include this line:
//** The original 'free' version of this script came from THE PARTICLE LABORATORY. **//
 
// SETUP:  Drop one optional particle texture and this script into a prim.
// Particles should start automatically. (Reset) the script if you insert a
// particle texture later on.  Add one or more CONTROLLER TEMPLATES to any
// prims in the linked object to control when particles turn ON and OFF.
 
// Customize the particle_parameter values below to create your unique 
// particle effect and click SAVE.  Values are explained along with their
// min/max and default values further down in this script.
 
// converted for pattern spread by Joris Tolsen
// -----------------------------------
// parameters ------------------------
// -- square mode --
float row_space 0.5;
float plant_space 0.5;        // used by circle and random too
float plant_offset 0.0;
integer rows 8;
integer plants 8;
// -- random mode --
integer rand_plants 30;
float rand_width 15.0;
float rand_depth 12.0;           
// -------------------
float   scale 0.5;
integer Handle;
integer Channel 1;
integer active 1;
integer pattern 0;          // 0 = square, 1 = random, 2 = circle
list    plant_list = [];
// ----------------------------------
list particle_parameters=[]; // stores your custom particle effect, defined below.
list target_parameters=[]; // remembers targets found using TARGET TEMPLATE scripts.
maak_part(float distance,float angle,string texture){
        
particle_parameters = [  // start of particle settings
           // Texture Parameters:
           
PSYS_SRC_TEXTURE,   texture,    //llGetInventoryName(INVENTORY_TEXTURE, 0), 
           
PSYS_PART_START_SCALE, &ltscale ,scaleFALSE>,  
           
PSYS_PART_END_SCALE, &ltscale ,scaleFALSE>, 
           
PSYS_PART_START_COLOR, &lt1,1,1>,    
           
PSYS_PART_END_COLOR, &lt1,1,1>, 
           
PSYS_PART_START_ALPHA, (float)1,            
           
PSYS_PART_END_ALPHA, (float)1,     
           
// Production Parameters:
           
PSYS_SRC_BURST_PART_COUNT2
           
PSYS_SRC_BURST_RATE, (float) 0.01,  
           
PSYS_PART_MAX_AGE, (float)30.0
           
PSYS_SRC_MAX_AGE,(float) 0.0,  
           
// Placement Parameters:
           
PSYS_SRC_PATTERN, (integer)4// 1=DROP, 2=EXPLODE, 4=ANGLE, 8=ANGLE_CONE,
           // Placement Parameters (for any non-DROP pattern):
           
PSYS_SRC_BURST_SPEED_MIN, (float)0,   
           
PSYS_SRC_BURST_SPEED_MAX, (float)0
           
PSYS_SRC_BURST_RADIUSdistance,
           
// Placement Parameters (only for ANGLE & CONE patterns):
           
PSYS_SRC_ANGLE_BEGINangle,     
           
PSYS_SRC_ANGLE_ENDangle,  
        
// PSYS_SRC_OMEGA, <0,0,0>, 
           // After-Effect & Influence Parameters:
        //   PSYS_SRC_ACCEL, <0.0,0.0,0.01>,  
        // PSYS_SRC_TARGET_KEY,      llGetLinkKey(llGetLinkNum() + 1),       
           
PSYS_PART_FLAGS, (integer)( 0         // Texture Options:     
                             //   | PSYS_PART_INTERP_COLOR_MASK   
                             //   | PSYS_PART_INTERP_SCALE_MASK   
                             //   | PSYS_PART_EMISSIVE_MASK   
                             //   | PSYS_PART_FOLLOW_VELOCITY_MASK
                                                  // After-effect & Influence Options:
                             //   | PSYS_PART_WIND_MASK            
                             //   | PSYS_PART_BOUNCE_MASK          
                             // | PSYS_PART_FOLLOW_SRC_MASK     
                             // | PSYS_PART_TARGET_POS_MASK     
                             // | PSYS_PART_TARGET_LINEAR_MASK   
                            

            
//end of particle settings                     
        
];
        
llParticleSystemparticle_parameters );
}
// ---------------------------------
// calculate where the plants go
// ---------------------------------
planten(){
    if (
pattern==0){
        
planten_square();
    } 
    else if (
pattern==1){
        
planten_list();
    }
}
planten_square(){
    
integer plants_row=0;       // will be set by script !!!
    
integer plants_row_odd=0;   // will be set by script !!
    
integer number llGetInventoryNumber(INVENTORY_TEXTURE);
    
integer textcnt=0;
    
vector begin_pos;
    
vector thrower_pos;
    
integer rc;     // row counter
    
integer pc;     // plant counter
    
float rl=0.0;   // row length
    
float fl=0.0;   // field length
    
begin_pos=llGetPos();
    
thrower_pos=llGetPos();
    
plants_row=plants/2;
    if (
plants plants_row plants_row 0){
        
plants_row_odd=1;
    }
    if (
rows 1){
        
fl rows*row_space-row_space;
        
begin_pos.x-=fl/2.0;
    }
    if (
plants_row 1){
        
rl=plants_row*plant_space-plant_space;
    }
    if (!
plants_row_odd){
        
begin_pos.y+=plant_space/2.0;       // even number of rows  .. take offset
    
}
    
begin_pos.x+=plant_offset;
     for(
rc=0rcrows rc++){
        
float rx=begin_pos.x+rc*row_space;
        for (
pc=0pc<plants_row+plants_row_odd;pc++){
            
float py=begin_pos.y+pc*plant_space;
            
float dst;
            
float ang;
            
float ro=rx-thrower_pos.x;
            
float po=py-thrower_pos.y;
            
dst llSqrt(ro*ro+po*po);
            
ang llAtan2(po,ro);
            
maak_part(dst,ang,llGetInventoryName(INVENTORY_TEXTURE,textcnt));
            if (++
textcnt >= numbertextcnt=0;
            
llSleep(0.05);
        }
    }
    
llParticleSystem([]);
}
planten_list(){
    
integer planten llGetListLength(plant_list);       // will be set by script !!!
    
vector pos;
    
vector thrower_pos;
    
vector begin_pos;
    
integer pc;     // plant counter
    
thrower_pos=llGetPos();
    
begin_pos=thrower_pos;
    
begin_pos.x+=plant_offset;
    for (
pc=0pcplanten pc++){
        
vector pp;
        
pp=llList2Vector(plant_list,pc);
        
float px=begin_pos.x+pp.x;
        
float py=begin_pos.y+pp.y;
        
float dst;
        
float ang;
        
float ro=px-thrower_pos.x;
        
float po=py-thrower_pos.y;
        
dst llSqrt(ro*ro+po*po);
        
ang llAtan2(po,ro);
        
maak_part(dst,ang,llGetInventoryName(INVENTORY_TEXTURE,(integer)llFloor(pp.z)));
        
llSleep(0.05);
    }
    
llParticleSystem([]);
}
maak_list(){
    
plant_list=[];
    
integer pc;     // plant counter
    
integer number llGetInventoryNumber(INVENTORY_TEXTURE);
    
float hpd=plant_space/2.0;
    
float dpt=(rand_depth-plant_space)/2.0;
    for (
pc=0pc<rand_plants;pc++) {
        
integer fout=0;
        
vector pp;
        do{
            
fout=0;
            
pp=<llFrand(rand_width)-(rand_width/2),llFrand(dpt)+hpd,llFrand(number)>;
            
// check distance
            
integer len llGetListLength(plant_list);
            if (
len 0){
                
integer tel;
                for (
tel=0;!fout && tel len ;tel++){
                    
vector lp=llList2Vector(plant_list,tel);
                    if (
llVecDist(lp,pp)<plant_space){
                        
fout=1;
                    }
                }
            }
        } 
        while (
fout);
        
plant_list += [pp];
    }
}
// -------------------------------------
// check if and which command is in str
// -------------------------------------
string checkMatchstring str, list prefixes  ){
    
integer numElements llGetListLengthprefixes );
    
integer i;
    
integer lastChar;
    
string curPrefix;
    
string curStr llToLowerstr );
    for( 
i=0i<numElementsi++ ){
        
curPrefix llList2String(prefixesi);
        
lastChar llStringLengthcurPrefix );
        
lastChar -= 1;
        if ( 
llGetSubString(curStr0lastChar) == curPrefix )
           return 
curPrefix;
    }
    return 
"";
}
help(){
    
llOwnerSay("command format /"+(string)Channel+" command value");
    
llOwnerSay("commands recognized :");
    
llOwnerSay("uit off stop        : switch the particles off");
    
llOwnerSay("aan on start        : switch the particles on");
    
llOwnerSay("regels rows         : number of rows to plant");
    
llOwnerSay("plants planten      : number of plants per row/random patern");
    
llOwnerSay("offset plaats       : shift the rows away from the center");
    
llOwnerSay("plantspace          : space between plants");
    
llOwnerSay("rowspace            : space between rows");
    
llOwnerSay("show toon           : make spreader visible");
    
llOwnerSay("hide verstop        : hide the spreader");
    
llOwnerSay("square              : square plants in rows");
    
llOwnerSay("random              : generate random pattern");
    
llOwnerSay("width               : width of the random pattern");
    
llOwnerSay("depth               : dept of the random pattern");
    
llOwnerSay("scale               : scale factor of the particle");
}
init(){
    
llSetTimerEvent(12.5);
    
planten();
    
Handle llListen(Channel""llGetOwner(), "");
    
active=1;
    if (
pattern == 1maak_list();
}
 
default{
 
    
state_entry(){
        
llOwnerSay("Commands == /"+(string)Channel+" help ");
        
init();
    }
 
    
on_rez(integer count){
        
llResetScript();
    }
 
    
timer(){
        
planten();
    }
 
    
touch_start(integer count){
        if (
active){
            
llSetTimerEvent(0.0);
            
active=0;
        }
        else{
            
init();
        }
    }
 
    
listen(integer channel,string name,key id,string message) {
        
string match;
        
integer divide=llSubStringIndex(message," ");
        
string gSubCommand llToLower(llGetSubString(messagedivide 140)); // grab the rest of the input string.
        
match checkMatchmessage, ["offset""plaats"] );
        if( 
match != "" ) {
            
plant_offset=(float)gSubCommand;
        } else {
         
match checkMatchmessage, ["uit""off""stop"] );
        if( 
match != "" ) {
             
llSetTimerEvent(0.0);
             
active=0;
        } else {
        
match checkMatchmessage, ["aan""on""start"] );
        if( 
match != "" ) {
             
init();
        } else {
        
match checkMatchmessage, ["plantspace""plantafstand"] );
        if( 
match != "" ) {
            
plant_space=(float)gSubCommand;
        } else {
        
match checkMatchmessage, ["rowspace""rijafstand"] );
        if( 
match != "" ) {
            
row_space=(integer)gSubCommand;
        } else {
        
match checkMatchmessage, ["rows""regels"] );
        if( 
match != "" ) {
            
integer rw=0;
            
rw=(integer)gSubCommand;
            if (
rw 0rows rw;           
        } else { 
        
match checkMatchmessage, ["plants""planten"] );
        if( 
match != "" ) {
            
integer pl=0;
            
pl=(integer)gSubCommand;
            if (
pl 0) {
                if (
pattern == 1) {
                    
rand_plants=pl;
                    
maak_list();
                } else {
                    
plants=pl;
                }
            }
        } else {
        
match checkMatchmessage, ["show""toon"] );
        if( 
match != "" ) {
            
llSetAlpha(1.0,ALL_SIDES);
        } else {
        
match checkMatchmessage, ["hide""verstop"] );
        if( 
match != "" ) {
             
llSetAlpha(0.0,ALL_SIDES);
        } else {
        
match checkMatchmessage, ["width"] );
        if( 
match != "" ) {
            
rand_width=(float)gSubCommand;
        } else {
        
match checkMatchmessage, ["depth"] );
        if( 
match != "" ) {
            
rand_depth=(float)gSubCommand;
        } else {
        
match checkMatchmessage, ["square"] );
        if( 
match != "" ) {
            
pattern=0;
        } else {
        
match checkMatchmessage, ["random"] );
        if( 
match != "" ) {
            
pattern=1;
            
maak_list();
        } else {
        
match checkMatchmessage, ["scale"] );
        if( 
match != "" ) {
            
scale = (float)gSubCommand;
        } else {
            
help();
        }}}}}}}}}}}}}}
    }

Reply




Messages In This Thread
Particle Positioning-Garden - by deadpool - 02-19-2013, 02:26 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Particle Glitching Effects maxio 0 572 10-06-2019, 06:57 PM
Last Post: maxio
  Particle aura monsterx3000 0 1,123 09-04-2018, 09:56 PM
Last Post: monsterx3000
  electricity shaped lightning particle Berkeley 1 1,784 07-11-2018, 04:53 AM
Last Post: SANEK9698
  Lightning particle Berkeley 0 1,288 07-04-2018, 12:05 PM
Last Post: Berkeley
  Particle Generator ZeroThe10th 5 6,993 05-07-2018, 11:30 AM
Last Post: Credair
  GLE's Flying Faggot Particle NigronPr1m3 1 3,165 03-14-2018, 08:57 AM
Last Post: ELiteRose
  Nice "star" rain type particle NaTaS 2 4,224 09-28-2016, 03:46 PM
Last Post: max144
  Red Firefly Particle ☠ MosDef ☠ 0 2,388 02-20-2013, 11:07 PM
Last Post: ☠ MosDef ☠
  Particle Targeting deadpool 0 2,588 02-19-2013, 02:19 AM
Last Post: deadpool

Forum Jump:

1 Guest(s)
Share this:

About Second Life Copybot

Second Life CopyBot Forum is a place where you can get items for Second Life and other vitual worlds for free. With our CopyBot viewers you can export and import any content from these virtual worlds and modify them in 3D software such as Blender, 3D studio Macx etc...