Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Particle Questionaire :)

Mike Zidane
Registered User
Join date: 10 Apr 2004
Posts: 255
01-28-2005 10:27
I did this because I tend to use Ama's script to create particles. But her script isn't really suitable for production in most of the cases I have encountered. So I end up needing to take that effect and rework it into a different script what behaves a little more professionally.

The point of this is to have particle creation a little easier The define_effect() function is supposed to read like a questionaire. less need for comments, and less thinking about what an oddly named variable is used for. This is kinda like fill in the blanks.

At least, that was my intention. :)

This script is meant to be used in a 'production environment'. You name your effect, define it in the define effect function, and drop the script on a prim. The effect fires on a linkmessage containing the name of the effect. You can also touch the object to make the effect fire (for testing purposes). Also supports a start delay.

I'm releasing this into the public domain in case someone finds in useful.

If you make any improvements to this script in functionality or readability, please post your new version for us all to enjoy. That's a condition of use, by the way. :D

Also, it seems to me like a lot of code-to-be-edited is meant to be glanced at, and then changed. This code is meant to be read. So read it :)


// Particle Script by Mike Zidane
// Do what you want with this, but keep it free and post your changes to the boards.

// Give this effect a name, and when it hears it's name called via linkmessage,
// it will wait for START_DELAY to expire, then then fire.
// Define your effect in the define_effect() function.

string EFFECT_NAME = "bubbles";

float START_DELAY = 0;

//Don't muck around with the declarations.
integer flags;
integer we_want_the_particle_to_glow;
integer we_want_the_particle_to_bounce;
integer we_want_the_particle_to_change_color;
integer we_want_the_particle_to_change_size;
integer we_want_the_particle_to_follow_wind;
integer we_want_the_particle_to_follow_its_source;
integer we_want_the_particle_to_spin_as_it_turns;
key we_want_the_effect_to_move_towards;
float we_want_each_particle_to_last_for;
float the_fastest_particles_will_be_ejected_at;
float the_slowest_particles_will_be_ejected_at;
string each_particle_should_have_this_texture;
float when_a_particle_is_created_it_will_have_an_alpha_value_of;
float and_then_it_will_gradually_shift_to_an_alpha_value_of;
vector when_a_particle_is_created_it_will_have_a_color_value_of;
vector and_then_it_will_gradually_shift_to_a_color_value_of;
vector new_particles_start_at_this_size;
vector and_change_to_this_size;
vector apply_this_constant_force_to_our_particles;
float we_want_to_create_new_particles_every;
float create_new_particles_this_far_from_the_prim;
integer create_this_number_of_particles_at_a_time;
float particles_should_fan_out_this_wide;
float spin_the_fan_this_far_around_the_center_of_the_emitter;
vector the_emmitter_will_spin_at_this_rate;
float the_emmitter_will_create_particles_for_this_long;
integer none = PSYS_SRC_PATTERN_DROP;
integer we_want_the_effect_to_be_shaped_like_a;

//Don't muck around with the functions either.
float randBetween(float min, float max)
return llFrand(max - min) + min;

wait_for(float delay)

//except this one. This is where you do your thing.
we_want_the_particle_to_glow = FALSE;

we_want_the_particle_to_bounce = FALSE;

we_want_the_particle_to_change_color = FALSE;

we_want_the_particle_to_change_size = TRUE;

we_want_the_particle_to_follow_wind = TRUE;

we_want_the_particle_to_follow_its_source = FALSE;

we_want_the_particle_to_spin_as_it_turns = TRUE;

we_want_the_effect_to_be_shaped_like_a = cone
// burst
// empty_cone
// cone
// fan
// none (= DROP)

we_want_the_effect_to_move_towards = ""; //(use a key,self,or owner inside the quotes)

we_want_each_particle_to_last_for = 10.0; //seconds.

the_fastest_particles_will_be_ejected_at = 0.750; // meters per second.

the_slowest_particles_will_be_ejected_at = 0.250; // meters per second.

each_particle_should_have_this_texture = "fda6b800-b2c5-e859-5c1a-27a88457f7df";
//(a key is preferred here. use "" for none.)

when_a_particle_is_created_it_will_have_an_alpha_value_of = 0.5;
//(0.0 is transparent, 1.0 is opaque.)

and_then_it_will_gradually_shift_to_an_alpha_value_of = 0.1;
//over the life of the particle.

when_a_particle_is_created_it_will_have_a_color_value_of = <1.0,1.0,1.0>;

and_then_it_will_gradually_shift_to_a_color_value_of = <1.0,1.0,1.0>;
//over the life of the particle.

new_particles_start_at_this_size = <0.1,0.1,0.1>;

and_change_to_this_size = <0.25,0.25,0.25>;
//over the life of the particle.

apply_this_constant_force_to_our_particles = <0.0,0.0,0.0005>;

we_want_to_create_new_particles_every = 0.1; //seconds.

create_new_particles_this_far_from_the_prim = 0.0; //for burst patterns only.

create_this_number_of_particles_at_a_time = 2;

//for angle patterns,
particles_should_fan_out_this_wide = 0; //in radians

spin_the_fan_this_far_around_the_center_of_the_emitter = 0; //,also in radians.

the_emmitter_will_spin_at_this_rate = <0,0,0>;

the_emmitter_will_create_particles_for_this_long = 2; //in seconds


//definitely definitely do not mess with this.
flags = 0;
if (we_want_the_effect_to_move_towards == "owner") we_want_the_effect_to_move_towards = llGetOwner();
if (we_want_the_effect_to_move_towards == "self") we_want_the_effect_to_move_towards = llGetKey();
if (we_want_the_particle_to_glow) flags = flags | PSYS_PART_EMISSIVE_MASK;
if (we_want_the_particle_to_bounce) flags = flags | PSYS_PART_BOUNCE_MASK;
if (we_want_the_particle_to_change_color) flags = flags | PSYS_PART_INTERP_COLOR_MASK;
if (we_want_the_particle_to_change_size) flags = flags | PSYS_PART_INTERP_SCALE_MASK;
if (we_want_the_particle_to_follow_wind) flags = flags | PSYS_PART_WIND_MASK;
if (we_want_the_particle_to_follow_its_source) flags = flags | PSYS_PART_FOLLOW_SRC_MASK;
if (we_want_the_particle_to_spin_as_it_turns) flags = flags | PSYS_PART_FOLLOW_VELOCITY_MASK;
if (we_want_the_effect_to_move_towards != "") flags = flags | PSYS_PART_TARGET_POS_MASK;

llParticleSystem([ PSYS_PART_MAX_AGE,we_want_each_particle_to_last_for,
PSYS_PART_START_COLOR, when_a_particle_is_created_it_will_have_a_color_value_of,
PSYS_PART_END_COLOR, and_then_it_will_gradually_shift_to_a_color_value_of,
PSYS_SRC_PATTERN, we_want_the_effect_to_be_shaped_like_a,
PSYS_SRC_ACCEL, apply_this_constant_force_to_our_particles,
PSYS_SRC_OMEGA, the_emmitter_will_spin_at_this_rate,
PSYS_SRC_MAX_AGE, the_emmitter_will_create_particles_for_this_long,
PSYS_SRC_TEXTURE, each_particle_should_have_this_texture,
PSYS_PART_START_ALPHA, when_a_particle_is_created_it_will_have_an_alpha_value_of,
PSYS_PART_END_ALPHA, and_then_it_will_gradually_shift_to_an_alpha_value_of

integer RUNNING = FALSE;




on_rez(integer NOT_USED)

touch_start(integer NOT_USED)

link_message(integer NoT_USED, integer NOt_USED, string the_passed_name, key NOT_uSED)
if (the_passed_name == EFFECT_NAME)

Yours truly, and hopin' it doesn't suck....

I'm only faking when I get it right. - CC
Chibi Madison
Registered User
Join date: 21 Jun 2004
Posts: 4
Original Thread
02-16-2005 08:26
Chibi Madison
Registered User
Join date: 21 Jun 2004
Posts: 4
Ahh I see..
02-16-2005 08:28
Yeah, I can definately see where variables named things such as we_want_the_particle_to_glow would be seen as more professional. ;)

Interesting idea though nontheless.

Alex Lumiere
Registered User
Join date: 1 Jun 2004
Posts: 228
03-12-2005 09:20
Chibi, I don't think that for it is professional as it is accessible and useable for the general public who doesn't know much about scripting.

In effect. he's created a text based GUI. Thanks Mike for releasing this.
Zindorf Yossarian
Master of Disaster
Join date: 9 Mar 2004
Posts: 160
04-08-2005 05:40
It's nice. I never thought of using variable names to make things more user-friendly, but that is a great idea.
Badass Ninja Penguin: Killing stuff it doesn't like since sometime in May 2004.
Mike Zidane
Registered User
Join date: 10 Apr 2004
Posts: 255
04-08-2005 09:01
hehe, yes, thank you, Alex, for understanding.

Heaven forbid that the layman should understand what he's lookin' at when reading code.
I'm only faking when I get it right. - CC
Kazuo Murakami
Sofa King
Join date: 31 Aug 2005
Posts: 359
09-18-2005 00:51
From: Mike Zidane
hehe, yes, thank you, Alex, for understanding.

Heaven forbid that the layman should understand what he's lookin' at when reading code.

As said layman, I thank ya. =P
Desmond Shang
Guvnah of Caledon
Join date: 14 Mar 2005
Posts: 5,250
09-27-2005 14:25
I find this script absolutely brilliant.

Having spent numerous editing episodes 'rediscovering' which parameters did what, simply because I did not remember the fairly obscure terminology.

Question: might I use a modified version of this in my items for sale, just for the sheer readability and ease of design?

Likely I would remove the link message functionality for most of my particular applications, pass on your original base script to all who ask, and forever speak well of your ability to cut through unnecessary, obfuscating mustard.
Desmond Shang
Guvnah of Caledon
Join date: 14 Mar 2005
Posts: 5,250
09-28-2005 11:35
The clarity of the variable names and their use is brilliant.

I constantly find myself setting the wrong parameter simply because I forgot which did what, or what the units were, &c.

Would you mind if I used portions of your script in products for sale?

I would forever exalt your name, and your ability to slice through pointless, obfuscating mustard.
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
11-12-2005 08:52
Bumping a fairly old thread but I've been dredging through the scripting library.

I was thinking it'd be interesting and useful to see this script then output a smaller cleaner version of the script when the user is happy with the parameters. It'd end up taking a lot more work on the coders part but should make the more novice scripters happy.

What does anyone think? Viable? How easy would it be to write a long text file (i.e. write the script from inside the script)?

nand Nerd
MeLight Korvin
Im on da Use
Join date: 4 Jun 2005
Posts: 99
11-12-2005 09:43
try this:
Particle Script Generator