Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Need your help for my script...

clara Hawks
Registered User
Join date: 15 Jan 2007
Posts: 3
09-15-2007 06:06
Hi all.

After made lovely saunas, i am trying to make showers but i have a problem with scripts that i fixed inside. I am not a specialist of scripts that's why i need your help.
This is what i did :

*In the button of the shower : i fixed 1 script
==========================================================
default
{
touch_start(integer total_number)
{
llMessageLinked(LINK_THIS, 0, "Touched.", NULL_KEY);
}
}
==========================================================





*In showerhead : i fixed 2 scripts

FIRST ONE==================================================

default
{
link_message(integer sender_num, integer num, string str, key id)
{
llSay(0,str);
}
}

SECOND ONE================================================

integer glow = TRUE; // Make the particles glow
integer bounce = FALSE; // Make particles bounce on Z plan of object
integer interpColor = TRUE; // Go from start to end color
integer interpSize = TRUE; // Go from start to end size
integer wind = FALSE; // Particles effected by wind
integer followSource = FALSE; // Particles follow the source
integer followVel = TRUE; // Particles turn to velocity direction
// Choose a pattern from the following:
// PSYS_SRC_PATTERN_EXPLODE
// PSYS_SRC_PATTERN_DROP
// PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY
// PSYS_SRC_PATTERN_ANGLE_CONE
// PSYS_SRC_PATTERN_ANGLE
integer pattern = PSYS_SRC_PATTERN_ANGLE_CONE;
// Select a target for particles to go towards
// "" for no target, "owner" will follow object owner
// and "self" will target this object
// or put the key of an object for particles to go to
key target = "";
// Particle paramaters
float age = 1.0; // Life of each particle
float maxSpeed = 3.0; // Max speed each particle is spit out at
float minSpeed = 1.0; // Min speed each particle is spit out at
string texture; // Texture used for particles, default used if blank
float startAlpha = 1; // Start alpha (transparency) value
float endAlpha = 1; // End alpha (transparency) value
vector startColor = <1,1,1>; // Start color of particles <R,G,B>
vector endColor = <1,1,1>; // End color of particles <R,G,B> (if interpColor == TRUE)
vector startSize = <0.02,0.1,0.02>; // Start size of particles
vector endSize = <0.04,0.1,0.04>; // End size of particles (if interpSize == TRUE)
vector push = <0,0,0>; // Force pushed on particles

// System paramaters
float rate = 0.1; // How fast (rate) to emit particles
float radius = 0.01; // Radius to emit particles for BURST pattern
integer count = 200; // How many particles to emit per BURST
float beginAngle = 0.2; // This is a NEW setting
float endAngle = 0; // This is a NEW setting
float outerAngle = 0.08; // Outer angle for all ANGLE patterns
float innerAngle = 0.9; // Inner angle for all ANGLE patterns
vector omega = <0,0,0>; // Rotation of ANGLE patterns around the source
float life = 0; // Life in seconds for the system to make particles
// Script variables
integer flags;
updateParticles()
{
flags = 0;
if (target == "owner";) target = llGetOwner();
if (target == "self";) target = llGetKey();
if (glow) flags = flags | PSYS_PART_EMISSIVE_MASK;
if (bounce) flags = flags | PSYS_PART_BOUNCE_MASK;
if (interpColor) flags = flags | PSYS_PART_INTERP_COLOR_MASK;
if (interpSize) flags = flags | PSYS_PART_INTERP_SCALE_MASK;
if (wind) flags = flags | PSYS_PART_WIND_MASK;
if (followSource) flags = flags | PSYS_PART_FOLLOW_SRC_MASK;
if (followVel) flags = flags | PSYS_PART_FOLLOW_VELOCITY_MASK;
if (target != "";) flags = flags | PSYS_PART_TARGET_POS_MASK;
llParticleSystem([ PSYS_PART_MAX_AGE,age,
PSYS_PART_FLAGS,flags,
PSYS_PART_START_COLOR, startColor,
PSYS_PART_END_COLOR, endColor,
PSYS_PART_START_SCALE,startSize,
PSYS_PART_END_SCALE,endSize,
PSYS_SRC_PATTERN, pattern,
PSYS_SRC_BURST_RATE,rate,
PSYS_SRC_ACCEL, push,
PSYS_SRC_BURST_PART_COUNT,count,
PSYS_SRC_BURST_RADIUS,radius,
PSYS_SRC_BURST_SPEED_MIN,minSpeed,
PSYS_SRC_BURST_SPEED_MAX,maxSpeed,
PSYS_SRC_TARGET_KEY,target,
PSYS_SRC_INNERANGLE,innerAngle,
PSYS_SRC_OUTERANGLE,outerAngle,
PSYS_SRC_ANGLE_BEGIN,beginAngle,
PSYS_SRC_ANGLE_END,endAngle,
PSYS_SRC_OMEGA, omega,
PSYS_SRC_MAX_AGE, life,
PSYS_SRC_TEXTURE, texture,
PSYS_PART_START_ALPHA, startAlpha,
PSYS_PART_END_ALPHA, endAlpha
]);
}
default
{
state_entry()
{
updateParticles();
}
}
=========================================================

Fixed like that it doesn't work... Could you explain why and correct my mistake?

You can contact me here or in SL.

Thank you
Auron Reardon
Registered User
Join date: 30 Jun 2006
Posts: 41
09-15-2007 06:45
I can see a couple of potential issues - but I'm not sure what you're trying to do. Can you describe what you want to happen?

The first thing I see is that your touch only results in one of the other scripts saying "touched" - but it doesn't do anything else. Did you want the touch to have some affect on the particles?
RaH Wollongong
Registered User
Join date: 11 Jul 2006
Posts: 19
09-15-2007 06:49
Double check your usage of llMessageLinked and link_message. I think in the first script you are telling the script to message itself.

http://wiki.secondlife.com/wiki/Link_message
http://wiki.secondlife.com/wiki/LlMessageLinked
Auron Reardon
Registered User
Join date: 30 Jun 2006
Posts: 41
09-15-2007 07:17
per RaH's comment, change:

llMessageLinked(LINK_THIS, 0, "Touched.", NULL_KEY);

to

llMessageLinked(LINK_SET, 0, "Touched.", NULL_KEY);

To have the showhead hear the shower's message. However, there will still be no affect on the particle system if that is what you're looking for.
clara Hawks
Registered User
Join date: 15 Jan 2007
Posts: 3
Thanks for your answers
09-15-2007 07:43
In fact, i would like when someone touch the button, the water (particles) runs through the showerhead.

I need for that to "link" the script in the button with the one in the showerhead, isn't it?
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
09-15-2007 08:54
Clara,

In the 2nd script you need to run the updateparticles() command not in state_entry() but in link_message(integer sender, integer int, string str, key id).

In addition to the changes to your link-message mentioned before...that should help you get a button-push to start the particles. Problem is, your script doesn't have any ability to turn the particles off.
_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
Auron Reardon
Registered User
Join date: 30 Jun 2006
Posts: 41
09-15-2007 09:04
>>i would like when someone touch the button, the water (particles) runs through the showerhead.>>

And, presumeably, if they touch it again for the particles to stop?

Assuming so, the first thing you need to do is respond to the link message you sent within the script that has the particle system.

So, take this bit from script 1 in the showerhead and move it to script 2 in the showerhead:

link_message(integer sender_num, integer num, string str, key id)
{
llSay(0,str);
}

At that point you can just delete script 1 in the showerhead because it is no longer doing anything.

Then, in script 2 in the showerhead, take your updateParticles() line from the state entry event and put it into the new link message event so that it looks like this:

state_entry()
{
}

link_message(integer sender_num, integer num, string str, key id)
{
updateParticles();
llSay(0,str);
}

That will turn it on. Now, I don't work with particles that much, but I believe to "turn off" a particle system, you have to declare a new one that does nothing to replace the running one. I'm not sure what all parameters would be for llParticleSystem to make a blank system. But once you figure that out, you could do this in script 2 of the showerhead:

integer nShowerOn = 0;

stopParticles()
{
llParticleSystem([a bunch of blank parameters]);
}

default
{

state_entry()
{
stopParticles();
}

link_message(integer sender_num, integer num, string str, key id)
{

if (nShowerOn == 0)
{
nShowerOn = 1;
updateParticles();
}
else
{
stopParticles();
nShowerOn = 0;
}

llSay(0,str);

}

}

For any particle experts out there, if I have this totally wrong, please correct me :)
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
09-15-2007 09:09
The call to stop particles is even simpler, just: llParticleSystem([]); --with a blank rule list.
clara Hawks
Registered User
Join date: 15 Jan 2007
Posts: 3
To resume...
09-15-2007 10:11
So in the button i put :

default
{
touch_start(integer total_number)
{
llMessageLinked(LINK_THIS, 0, "Touched.", NULL_KEY);
}
}






And in showerhead, only that :


integer glow = TRUE; // Make the particles glow
integer bounce = FALSE; // Make particles bounce on Z plan of object
integer interpColor = TRUE; // Go from start to end color
integer interpSize = TRUE; // Go from start to end size
integer wind = FALSE; // Particles effected by wind
integer followSource = FALSE; // Particles follow the source
integer followVel = TRUE; // Particles turn to velocity direction

// Choose a pattern from the following:
// PSYS_SRC_PATTERN_EXPLODE
// PSYS_SRC_PATTERN_DROP
// PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY
// PSYS_SRC_PATTERN_ANGLE_CONE
// PSYS_SRC_PATTERN_ANGLE
integer pattern = PSYS_SRC_PATTERN_ANGLE_CONE;

// Select a target for particles to go towards
// "" for no target, "owner" will follow object owner
// and "self" will target this object
// or put the key of an object for particles to go to
key target = "";

// Particle paramaters
float age = 1.0; // Life of each particle
float maxSpeed = 3.0; // Max speed each particle is spit out at
float minSpeed = 1.0; // Min speed each particle is spit out at
string texture; // Texture used for particles, default used if blank
float startAlpha = 1; // Start alpha (transparency) value
float endAlpha = 1; // End alpha (transparency) value
vector startColor = <1,1,1>; // Start color of particles <R,G,B>
vector endColor = <1,1,1>; // End color of particles <R,G,B> (if interpColor == TRUE)
vector startSize = <0.02,0.1,0.02>; // Start size of particles
vector endSize = <0.04,0.1,0.04>; // End size of particles (if interpSize == TRUE)
vector push = <0,0,0>; // Force pushed on particles


// System paramaters
float rate = 0.1; // How fast (rate) to emit particles
float radius = 0.01; // Radius to emit particles for BURST pattern
integer count = 200; // How many particles to emit per BURST
float beginAngle = 0.2; // This is a NEW setting
float endAngle = 0; // This is a NEW setting
float outerAngle = 0.08; // Outer angle for all ANGLE patterns
float innerAngle = 0.9; // Inner angle for all ANGLE patterns
vector omega = <0,0,0>; // Rotation of ANGLE patterns around the source
float life = 0; // Life in seconds for the system to make particles

// Script variables
integer flags;

updateParticles()
{
flags = 0;
if (target == "owner";) target = llGetOwner();
if (target == "self";) target = llGetKey();
if (glow) flags = flags | PSYS_PART_EMISSIVE_MASK;
if (bounce) flags = flags | PSYS_PART_BOUNCE_MASK;
if (interpColor) flags = flags | PSYS_PART_INTERP_COLOR_MASK;
if (interpSize) flags = flags | PSYS_PART_INTERP_SCALE_MASK;
if (wind) flags = flags | PSYS_PART_WIND_MASK;
if (followSource) flags = flags | PSYS_PART_FOLLOW_SRC_MASK;
if (followVel) flags = flags | PSYS_PART_FOLLOW_VELOCITY_MASK;
if (target != "";) flags = flags | PSYS_PART_TARGET_POS_MASK;

llParticleSystem([ PSYS_PART_MAX_AGE,age,
PSYS_PART_FLAGS,flags,
PSYS_PART_START_COLOR, startColor,
PSYS_PART_END_COLOR, endColor,
PSYS_PART_START_SCALE,startSize,
PSYS_PART_END_SCALE,endSize,
PSYS_SRC_PATTERN, pattern,
PSYS_SRC_BURST_RATE,rate,
PSYS_SRC_ACCEL, push,
PSYS_SRC_BURST_PART_COUNT,count,
PSYS_SRC_BURST_RADIUS,radius,
PSYS_SRC_BURST_SPEED_MIN,minSpeed,
PSYS_SRC_BURST_SPEED_MAX,maxSpeed,
PSYS_SRC_TARGET_KEY,target,
PSYS_SRC_INNERANGLE,innerAngle,
PSYS_SRC_OUTERANGLE,outerAngle,
PSYS_SRC_ANGLE_BEGIN,beginAngle,
PSYS_SRC_ANGLE_END,endAngle,

PSYS_SRC_OMEGA, omega,
PSYS_SRC_MAX_AGE, life,
PSYS_SRC_TEXTURE, texture,
PSYS_PART_START_ALPHA, startAlpha,
PSYS_PART_END_ALPHA, endAlpha
]);
}
default
{
state_entry()
{
}

link_message(integer sender_num, integer num, string str, key id)
{
updateParticles();
llSay(0,str);
}

integer nShowerOn = 0;
stopParticles()
{
llParticleSystem([a bunch of blank parameters]);
}

default
{

state_entry()
{
stopParticles();
}

link_message(integer sender_num, integer num, string str, key id)
{

if (nShowerOn == 0)
{
nShowerOn = 1;
updateParticles();
}
else
{
stopParticles();
nShowerOn = 0;
}

llSay(0,str);

}

}



They said "syntax error"... grrrrrr lol
Maybe just a pb of { ... or i understood in wrong way...
Auron Reardon
Registered User
Join date: 30 Jun 2006
Posts: 41
09-15-2007 18:09
Try this:

integer glow = TRUE; // Make the particles glow
integer bounce = FALSE; // Make particles bounce on Z plan of object
integer interpColor = TRUE; // Go from start to end color
integer interpSize = TRUE; // Go from start to end size
integer wind = FALSE; // Particles effected by wind
integer followSource = FALSE; // Particles follow the source
integer followVel = TRUE; // Particles turn to velocity direction

// Choose a pattern from the following:
// PSYS_SRC_PATTERN_EXPLODE
// PSYS_SRC_PATTERN_DROP
// PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY
// PSYS_SRC_PATTERN_ANGLE_CONE
// PSYS_SRC_PATTERN_ANGLE
integer pattern = PSYS_SRC_PATTERN_ANGLE_CONE;

// Select a target for particles to go towards
// "" for no target, "owner" will follow object owner
// and "self" will target this object
// or put the key of an object for particles to go to
key target = "";

// Particle paramaters
float age = 1.0; // Life of each particle
float maxSpeed = 3.0; // Max speed each particle is spit out at
float minSpeed = 1.0; // Min speed each particle is spit out at
string texture; // Texture used for particles, default used if blank
float startAlpha = 1; // Start alpha (transparency) value
float endAlpha = 1; // End alpha (transparency) value
vector startColor = <1,1,1>; // Start color of particles <R,G,B>
vector endColor = <1,1,1>; // End color of particles <R,G,B> (if interpColor == TRUE)
vector startSize = <0.02,0.1,0.02>; // Start size of particles
vector endSize = <0.04,0.1,0.04>; // End size of particles (if interpSize == TRUE)
vector push = <0,0,0>; // Force pushed on particles


// System paramaters
float rate = 0.1; // How fast (rate) to emit particles
float radius = 0.01; // Radius to emit particles for BURST pattern
integer count = 200; // How many particles to emit per BURST
float beginAngle = 0.2; // This is a NEW setting
float endAngle = 0; // This is a NEW setting
float outerAngle = 0.08; // Outer angle for all ANGLE patterns
float innerAngle = 0.9; // Inner angle for all ANGLE patterns
vector omega = <0,0,0>; // Rotation of ANGLE patterns around the source
float life = 0; // Life in seconds for the system to make particles

// Script variables
integer flags;

updateParticles()
{
flags = 0;
if (target == "owner";) target = llGetOwner();
if (target == "self";) target = llGetKey();
if (glow) flags = flags | PSYS_PART_EMISSIVE_MASK;
if (bounce) flags = flags | PSYS_PART_BOUNCE_MASK;
if (interpColor) flags = flags | PSYS_PART_INTERP_COLOR_MASK;
if (interpSize) flags = flags | PSYS_PART_INTERP_SCALE_MASK;
if (wind) flags = flags | PSYS_PART_WIND_MASK;
if (followSource) flags = flags | PSYS_PART_FOLLOW_SRC_MASK;
if (followVel) flags = flags | PSYS_PART_FOLLOW_VELOCITY_MASK;
if (target != "";) flags = flags | PSYS_PART_TARGET_POS_MASK;

llParticleSystem([ PSYS_PART_MAX_AGE,age,
PSYS_PART_FLAGS,flags,
PSYS_PART_START_COLOR, startColor,
PSYS_PART_END_COLOR, endColor,
PSYS_PART_START_SCALE,startSize,
PSYS_PART_END_SCALE,endSize,
PSYS_SRC_PATTERN, pattern,
PSYS_SRC_BURST_RATE,rate,
PSYS_SRC_ACCEL, push,
PSYS_SRC_BURST_PART_COUNT,count,
PSYS_SRC_BURST_RADIUS,radius,
PSYS_SRC_BURST_SPEED_MIN,minSpeed,
PSYS_SRC_BURST_SPEED_MAX,maxSpeed,
PSYS_SRC_TARGET_KEY,target,
PSYS_SRC_INNERANGLE,innerAngle,
PSYS_SRC_OUTERANGLE,outerAngle,
PSYS_SRC_ANGLE_BEGIN,beginAngle,
PSYS_SRC_ANGLE_END,endAngle,

PSYS_SRC_OMEGA, omega,
PSYS_SRC_MAX_AGE, life,
PSYS_SRC_TEXTURE, texture,
PSYS_PART_START_ALPHA, startAlpha,
PSYS_PART_END_ALPHA, endAlpha
]);
}
default
{
state_entry()
{
}

link_message(integer sender_num, integer num, string str, key id)
{
updateParticles();
llSay(0,str);
}

integer nShowerOn = 0;
stopParticles()
{
llParticleSystem([]);
}

default
{

state_entry()
{
stopParticles();
}

link_message(integer sender_num, integer num, string str, key id)
{

if (nShowerOn == 0)
{
nShowerOn = 1;
updateParticles();
}
else
{
stopParticles();
nShowerOn = 0;
}

llSay(0,str);

}

}
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
09-15-2007 18:49
If this linkset only has the showerhead that needs to do something scripted then you could actually make your script much easier. You do not need to put a script at all in the shower handle and instead of llMessageLinked in the shower head, you use touch_start. Whenever they touch the shower handle then the touch is passed to the shower head. Then in your particle script you could either change states to switch from the NULL particle script to the regular one or use the touch integer.

I know, I know it sounds complicated, but it is actually pretty easy. I'll get a chance to code it up in a little while.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
09-15-2007 20:17
This works perfectly with no script in the handle. Just right click edit and pick the handle first and then the shower head when you link:

CODE

integer shower = 1;
integer glow = TRUE; // Make the particles glow
integer bounce = FALSE; // Make particles bounce on Z plan of object
integer interpColor = TRUE; // Go from start to end color
integer interpSize = TRUE; // Go from start to end size
integer wind = FALSE; // Particles effected by wind
integer followSource = FALSE; // Particles follow the source
integer followVel = TRUE; // Particles turn to velocity direction
// Choose a pattern from the following:
// PSYS_SRC_PATTERN_EXPLODE
// PSYS_SRC_PATTERN_DROP
// PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY
// PSYS_SRC_PATTERN_ANGLE_CONE
// PSYS_SRC_PATTERN_ANGLE
integer pattern = PSYS_SRC_PATTERN_ANGLE_CONE;
// Select a target for particles to go towards
// "" for no target, "owner" will follow object owner
// and "self" will target this object
// or put the key of an object for particles to go to
key target = "";
// Particle paramaters
float age = 1.0; // Life of each particle
float maxSpeed = 3.0; // Max speed each particle is spit out at
float minSpeed = 1.0; // Min speed each particle is spit out at
string texture; // Texture used for particles, default used if blank
float startAlpha = 1; // Start alpha (transparency) value
float endAlpha = 1; // End alpha (transparency) value
vector startColor = <1,1,1>; // Start color of particles <R,G,B>
vector endColor = <1,1,1>; // End color of particles <R,G,B> (if interpColor == TRUE)
vector startSize = <0.02,0.1,0.02>; // Start size of particles
vector endSize = <0.04,0.1,0.04>; // End size of particles (if interpSize == TRUE)
vector push = <0,0,0>; // Force pushed on particles

// System paramaters
float rate = 0.1; // How fast (rate) to emit particles
float radius = 0.01; // Radius to emit particles for BURST pattern
integer count = 200; // How many particles to emit per BURST
float beginAngle = 0.2; // This is a NEW setting
float endAngle = 0; // This is a NEW setting
float outerAngle = 0.08; // Outer angle for all ANGLE patterns
float innerAngle = 0.9; // Inner angle for all ANGLE patterns
vector omega = <0,0,0>; // Rotation of ANGLE patterns around the source
float life = 0; // Life in seconds for the system to make particles
// Script variables
integer flags;
updateParticles()
{
flags = 0;
if (target == "owner") target = llGetOwner();
if (target == "self") target = llGetKey();
if (glow) flags = flags | PSYS_PART_EMISSIVE_MASK;
if (bounce) flags = flags | PSYS_PART_BOUNCE_MASK;
if (interpColor) flags = flags | PSYS_PART_INTERP_COLOR_MASK;
if (interpSize) flags = flags | PSYS_PART_INTERP_SCALE_MASK;
if (wind) flags = flags | PSYS_PART_WIND_MASK;
if (followSource) flags = flags | PSYS_PART_FOLLOW_SRC_MASK;
if (followVel) flags = flags | PSYS_PART_FOLLOW_VELOCITY_MASK;
if (target != "") flags = flags | PSYS_PART_TARGET_POS_MASK;
llParticleSystem([ PSYS_PART_MAX_AGE,age,
PSYS_PART_FLAGS,flags,
PSYS_PART_START_COLOR, startColor,
PSYS_PART_END_COLOR, endColor,
PSYS_PART_START_SCALE,startSize,
PSYS_PART_END_SCALE,endSize,
PSYS_SRC_PATTERN, pattern,
PSYS_SRC_BURST_RATE,rate,
PSYS_SRC_ACCEL, push,
PSYS_SRC_BURST_PART_COUNT,count,
PSYS_SRC_BURST_RADIUS,radius,
PSYS_SRC_BURST_SPEED_MIN,minSpeed,
PSYS_SRC_BURST_SPEED_MAX,maxSpeed,
PSYS_SRC_TARGET_KEY,target,
PSYS_SRC_INNERANGLE,innerAngle,
PSYS_SRC_OUTERANGLE,outerAngle,
PSYS_SRC_ANGLE_BEGIN,beginAngle,
PSYS_SRC_ANGLE_END,endAngle,
PSYS_SRC_OMEGA, omega,
PSYS_SRC_MAX_AGE, life,
PSYS_SRC_TEXTURE, texture,
PSYS_PART_START_ALPHA, startAlpha,
PSYS_PART_END_ALPHA, endAlpha
]);
}
default
{
touch_start(integer n)
{
if(shower == 1){
shower = 0;
updateParticles();
}
else{
shower = 1;
llParticleSystem([]);
}
}
}
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum