Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Night and day particle/sound switcher

Poppet McGimsie
Proprietrix, WUNDERBAR
Join date: 28 Jul 2006
Posts: 197
03-18-2007 11:11
Doncha just hate it when your fireflies refuse to go to bed and keep lighting up all day too? And when those dang birds won't sleep at night, but keep flying and singing all night long??? Well, then, this script is for you. It switches between fireflies and looping nightsounds when the sun is down, and switches automatically to episodes of gulls crying and flying up into the sky during the day. You can of course put in bats instead of fireflies, for example, or butterflies instead of gulls -- or anything you want!

This script is offered free, and must remain so!

CODE
//Night and Day particles and sounds

//looping nightsounds and fireflies only at night
//episodic gullflught and gull cries during the day
//two independent particle systens
//drop in a prim to have fireflies and summer night sounds only when the sun is down and gulls crying out and flying off every couple of minutes (you won't see gulls the first time the timer triggers during the day cause you gotta prime the queue)
//change the sound and texture uuid's too suit your taste.
//Poppet McGimsie, 3/18/2007
// particle system from Angela Salome, /15/36/124969/1.html
// Particle System Template.
// Derived from Jopsy's Particle System Template, which is derived from Ama Omega's Particle script.
//thus script is freeware, and must be set with full permissions whenever it is used, and never sold.

//Nighttime particle system
// Appearance - how each particle looks.
// Start & End refers to the birth & death of each particle.

string Texturen = "a6b6e78a-6b7b-9f26-5bca-22f417d077ef";

integer Interpolate_Scalen = TRUE; // Turns on or off interpolating scale.
vector Start_Scalen = < 0.1,0.1, 0.0 >; // Particle height & width, from 0.04 to 4.0.
vector End_Scalen = < 0.5,0.5, 0.0 >; // No depth; Z is ignored.

integer Interpolate_Colourn = TRUE; // Turns on or off interpolating colour.
vector Start_Colourn = < 1.0, 1.0, 0.0 >; // Colour vector: <R, G, B>.
vector End_Colourn = < 1.0, 1.0, 0.0 >; // 1.0 = Full colour; 0.0 = Zero colour.

float Start_Alphan = 0.0; // Sets transparency, from invisible = 0.0 to opaque = 1.0.
float End_Alphan = 0.70;

integer Emissiven = TRUE;


// Flow - these settings affect how many, how quickly and for how long particles are present.

float Agen = 2.; // How many seconds each particle lives for: 0.1 to 60.0 seconds.
float Raten = 0.1; // Seconds between particle bursts, 0.0 to 60.
integer Countn = 1; // Number of particles per burst, 1 to 4096.
float Lifen = 0.0; // Number of seconds to wait before shutting off, 0.1 to 60. 0.0 never stops.


// Placement - where new particles are created and what direction are they facing?

// Pattern must be set to one of the following:
// PSYS_SRC_PATTERN_EXPLODE // Sends particles in all directions.
// PSYS_SRC_PATTERN_DROP // Ignores Speed.
// PSYS_SRC_PATTERN_ANGLE_CONE // Uses Angle values to make rings & cones.
// PSYS_SRC_PATTERN_ANGLE // Uses ___ to make flat wedges.

integer Patternn = PSYS_SRC_PATTERN_EXPLODE;

float Radiusn = 5.0; // Distance between emitter and each new particle, 0.0 to 64?

float Begin_Anglen = 0.0; // 0 - PI (3.14159).
float End_Anglen = 0.0; // 0 - PI (3.14159).

vector Omegan = < 0.0, 0.0, 0.0 >; // How much to rotate the emitter around the X, Y & Z axes after each burst.


// Movement - moving the particles after they're created.

integer Follow_Sourcen = FALSE; // Moves particles when emitter moves. Disables Radius.
integer Follow_Velocityn = TRUE; // Particles rotate towards their heading.
integer Windn = FALSE; // Sim's wind will push particles.
integer Bouncen = FALSE; // Make particles bounce above the Z altitude of emitter.

float Minimum_Speedn = 0.02; // 0.01 to ?, slowest speed of new particles.
float Maximum_Speedn = 0.05; // 0.01 to ?, fastest speed of new particles.
// Speed is ignore by PSYS_SRC_PATTERN_DROP Pattern.

vector Accelerationn = < 0.00, 0.0, 1.9 >; // A continous force pushed on particles. Use small settings for long lived particles.

integer Targetn = FALSE; // Turns on or off targeting of particles.
key Target_Keyn = NULL_KEY; // Not sure.
// key Target_Key = llGetKey (); // Particles return to the emitter.
// key Target_Key = llGetOwner (); // Particles target the owner.
// You can have another object llSay (999, llGetKey ());
// and grab the key for that object by using the listen () event handler.

Particle_System_night ()
{
list Parameters =
[
PSYS_PART_FLAGS,
(
(Emissiven * PSYS_PART_EMISSIVE_MASK) |
(Bouncen * PSYS_PART_BOUNCE_MASK) |
(Interpolate_Colourn * PSYS_PART_INTERP_COLOR_MASK) |
(Interpolate_Scalen * PSYS_PART_INTERP_SCALE_MASK) |
(Windn * PSYS_PART_WIND_MASK) |
(Follow_Sourcen * PSYS_PART_FOLLOW_SRC_MASK) |
(Follow_Velocityn * PSYS_PART_FOLLOW_VELOCITY_MASK) |
(Targetn * PSYS_PART_TARGET_POS_MASK)
),
PSYS_PART_START_COLOR, Start_Colourn,
PSYS_PART_END_COLOR, End_Colourn,
PSYS_PART_START_ALPHA, Start_Alphan,
PSYS_PART_END_ALPHA, End_Alphan,
PSYS_PART_START_SCALE, Start_Scalen,
PSYS_PART_END_SCALE, End_Scalen,
PSYS_SRC_PATTERN, Patternn,
PSYS_SRC_BURST_PART_COUNT, Countn,
PSYS_SRC_BURST_RATE, Raten,
PSYS_PART_MAX_AGE, Agen,
PSYS_SRC_ACCEL, Accelerationn,
PSYS_SRC_BURST_RADIUS, Radiusn,
PSYS_SRC_BURST_SPEED_MIN, Minimum_Speedn,
PSYS_SRC_BURST_SPEED_MAX, Maximum_Speedn,
PSYS_SRC_TARGET_KEY, Target_Keyn,
PSYS_SRC_ANGLE_BEGIN, Begin_Anglen,
PSYS_SRC_ANGLE_END, End_Anglen,
PSYS_SRC_OMEGA, Omegan,
PSYS_SRC_MAX_AGE, Lifen,
PSYS_SRC_TEXTURE, Texturen
];
llParticleSystem (Parameters); // Turns on the particle system.
integer Particles = (integer) (Agen * (float) Countn / Raten);
if (4096 < Particles)
{
llOwnerSay ("Emitter (night) creates too many particles!");
}
llOwnerSay ("Emitter produces " + (string) Particles + " concurrent particles.");
}

//Daytime particle system
// Appearance - how each particle looks.
// Start & End refers to the birth & death of each particle.

string Textured = "cb2ba2e6-88ae-abd7-efd4-7ad85f0f0469";

integer Interpolate_Scaled = TRUE; // Turns on or off interpolating scale.
vector Start_Scaled = < 1.0,1.0, 0.0 >; // Particle height & width, from 0.04 to 4.0.
vector End_Scaled = < 1.0,1.0, 0.0 >; // No depth; Z is ignored.

integer Interpolate_Colourd = TRUE; // Turns on or off interpolating colour.
vector Start_Colourd = < 1.0, 1.0, 1.0>; // Colour vector: <R, G, B>.
vector End_Colourd = < 1.0, 1.0, 1.0 >; // 1.0 = Full colour; 0.0 = Zero colour.

float Start_Alphad = 0.70; // Sets transparency, from invisible = 0.0 to opaque = 1.0.
float End_Alphad = 0.70;

integer Emissived = FALSE;


// Flow - these settings affect how many, how quickly and for how long particles are present.

float Aged = 60.0; // How many seconds each particle lives for: 0.1 to 60.0 seconds.
float Rated = 1.0; // Seconds between particle bursts, 0.0 to 60.
integer Countd = 1; // Number of particles per burst, 1 to 4096.
float Lifed = 20.0; // Number of seconds to wait before shutting off, 0.1 to 60. 0.0 never stops.


// Placement - where new particles are created and what direction are they facing?

// Pattern must be set to one of the following:
// PSYS_SRC_PATTERN_EXPLODE // Sends particles in all directions.
// PSYS_SRC_PATTERN_DROP // Ignores Speed.
// PSYS_SRC_PATTERN_ANGLE_CONE // Uses Angle values to make rings & cones.
// PSYS_SRC_PATTERN_ANGLE // Uses ___ to make flat wedges.

integer Patternd = PSYS_SRC_PATTERN_EXPLODE;

float Radiusd = 5.0; // Distance between emitter and each new particle, 0.0 to 64?

float Begin_Angled = 0.0; // 0 - PI (3.14159).
float End_Angled = 0.0; // 0 - PI (3.14159).

vector Omegad = < 0.0, 0.0, 0.0 >; // How much to rotate the emitter around the X, Y & Z axes after each burst.


// Movement - moving the particles after they're created.

integer Follow_Sourced = FALSE; // Moves particles when emitter moves. Disables Radius.
integer Follow_Velocityd = TRUE; // Particles rotate towards their heading.
integer Windd = FALSE; // Sim's wind will push particles.
integer Bounced = FALSE; // Make particles bounce above the Z altitude of emitter.

float Minimum_Speedd = 0.02; // 0.01 to ?, slowest speed of new particles.
float Maximum_Speedd = 0.05; // 0.01 to ?, fastest speed of new particles.
// Speed is ignore by PSYS_SRC_PATTERN_DROP Pattern.

vector Accelerationd = < 0.00, 0.0, 1.9 >; // A continous force pushed on particles. Use small settings for long lived particles.

integer Targetd = FALSE; // Turns on or off targeting of particles.
key Target_Keyd = NULL_KEY; // Not sure.
// key Target_Key = llGetKey (); // Particles return to the emitter.
// key Target_Key = llGetOwner (); // Particles target the owner.
// You can have another object llSay (999, llGetKey ());
// and grab the key for that object by using the listen () event handler.

Particle_System_day ()
{
list Parameters =
[
PSYS_PART_FLAGS,
(
(Emissived * PSYS_PART_EMISSIVE_MASK) |
(Bounced * PSYS_PART_BOUNCE_MASK) |
(Interpolate_Colourd * PSYS_PART_INTERP_COLOR_MASK) |
(Interpolate_Scaled * PSYS_PART_INTERP_SCALE_MASK) |
(Windd * PSYS_PART_WIND_MASK) |
(Follow_Sourced * PSYS_PART_FOLLOW_SRC_MASK) |
(Follow_Velocityd * PSYS_PART_FOLLOW_VELOCITY_MASK) |
(Targetd * PSYS_PART_TARGET_POS_MASK)
),
PSYS_PART_START_COLOR, Start_Colourd,
PSYS_PART_END_COLOR, End_Colourd,
PSYS_PART_START_ALPHA, Start_Alphad,
PSYS_PART_END_ALPHA, End_Alphad,
PSYS_PART_START_SCALE, Start_Scaled,
PSYS_PART_END_SCALE, End_Scaled,
PSYS_SRC_PATTERN, Patternd,
PSYS_SRC_BURST_PART_COUNT, Countd,
PSYS_SRC_BURST_RATE, Rated,
PSYS_PART_MAX_AGE, Aged,
PSYS_SRC_ACCEL, Accelerationd,
PSYS_SRC_BURST_RADIUS, Radiusd,
PSYS_SRC_BURST_SPEED_MIN, Minimum_Speedd,
PSYS_SRC_BURST_SPEED_MAX, Maximum_Speedd,
PSYS_SRC_TARGET_KEY, Target_Keyd,
PSYS_SRC_ANGLE_BEGIN, Begin_Angled,
PSYS_SRC_ANGLE_END, End_Angled,
PSYS_SRC_OMEGA, Omegad,
PSYS_SRC_MAX_AGE, Lifed,
PSYS_SRC_TEXTURE, Textured
];
llParticleSystem (Parameters); // Turns on the particle system.
integer Particles = (integer) (Agen * (float) Countn / Raten);
if (4096 < Particles)
{
llOwnerSay ("Emitter (night) creates too many particles!");
}
llOwnerSay ("Emitter produces " + (string) Particles + " concurrent particles.");
}
default {
state_entry() {
llSetTimerEvent(60);
}
timer() {
vector sun = llGetSunDirection();
if(sun.z > 0) {
Particle_System_day () ;
llStopSound();
llTriggerSound("5c3eabf1-7005-a939-43ef-b10bb9a76189",1.0);
}
else {
Particle_System_night ();
llLoopSound("8cdeffa3-bbe2-762a-7fb8-6db22c7b24b2",1.0);
}
}
}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
03-21-2007 04:22
/15/ec/172164/1.html
_____________________
i've got nothing. ;)