Join us in Outworldz at www.outworldz.com:9000 or follow us:

How to make realistic water spout in Second Life™

In this post, I'll show you how to script a realistic spout that sprays from your whale.

You will need to add in another cube shaped prim and position it inside the whale. I positioned mine up near the blow-hole.

spout
Add the following script to that prim. It begins with a llParticleSystem call. This system call is passed a list, which basically means that there is a matching set of [...] inside the (.. )
Each CAPITALIZED parameter is a system variable that is set by a number, a vector, or a floating point number.

This particular setup will make a spray shaped a lot like a narrow spray of water shot from a hose. The jets will spurt out at high speed, from 1 to 5 seconds, in long narrow bursts. We'll store all this information in the subroutine updateParticles().

Download


updateParticles() 
{
	llParticleSystem([

	PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_ANGLE,
    	PSYS_SRC_MAX_AGE, 0.,  //partcile emitter always runs
    	PSYS_SRC_BURST_RATE, .3,	// about 3 bursts a sec
    	PSYS_SRC_BURST_PART_COUNT, 50,	// 50 at a whack = about 150 a second
     	PSYS_SRC_BURST_RADIUS, 1,		// particles appear about 1 meter above the prim Z axis
     	PSYS_SRC_BURST_SPEED_MIN, 1.,	// 1 meter 
     	PSYS_SRC_BURST_SPEED_MAX, 5.,	// to 5 meters spurts
     	PSYS_SRC_ACCEL, <0.0,0.0,-1.>,	// make them fall a bit
	PSYS_SRC_ANGLE_BEGIN, PI,		// a narrow emitter, like a spray hose
     	PSYS_SRC_ANGLE_END, PI,
     	PSYS_SRC_OMEGA, <0.,0.0,0.0>,	// no rotation
     	PSYS_PART_MAX_AGE, 4., 		// they last 4 second, so 4 * 150 = 600 particles are visible  
     	PSYS_PART_START_COLOR, <1,1,1>,	// white
     	PSYS_PART_END_COLOR, <1,1,1>,
     	PSYS_PART_START_ALPHA, .7,			// faded a bit
     	PSYS_PART_END_ALPHA, 0.1,			// faded a lot at the start
     	PSYS_PART_START_SCALE, <.08,.8,0>,	// long and narrow to make jets
	PSYS_PART_END_SCALE, <.05,.1,0>, PSYS_PART_FLAGS, 0 | PSYS_PART_INTERP_COLOR_MASK |
	PSYS_PART_INTERP_SCALE_MASK | PSYS_PART_FOLLOW_VELOCITY_MASK  | PSYS_PART_WIND_MASK]);

}

All Second life LSL scripts must have a default{..} procedure.� Inside that default{..} , between the starting { and ending } braces, is the code.� Once the script starts, it calls the state_entry(). state_entry() turns off the particle system.

default
{
	state_entry()
	{
		llParticleSystem([]);
	}

A link message is a prim-to-prim message. They are generated by llMessageLinked commands in the main script. When the main script runs the following code...

llMessageLinked(LINK_SET,0,"on",NULL_KEY);	// part of another script

and then the link_message function is called. In this script, we look for the 'on' or 'off' strings. If on, we call the particle subroutine. If Off, we pass a null list [] to the particle system.

	link_message(integer sender, integer num, string str, key id)
	{
		if (str == "on") {
			updateParticles();
			
		} else if (str == "off") {
			llParticleSystem([]);
		}
	}
}					



Next - > Part 6- Splash script - make your fish or whale splash water as it jumps

Back to the Best Free Tools in Second Life and OpenSim.