Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Particle Target question

Seph DaSilva
Registered User
Join date: 26 Apr 2005
Posts: 27
10-05-2005 16:47
When using the PSYS_SRC_TARGET_KEY, what I have read indicates I have three choices for targets: llGetKey(), llDetectedKey(0), and llGetOwner().

The former 2 result in the prim targeting itself, and the later targets the owner. When making prim wings, I've used llGetOwner and this works fairly well, but while moving, things get choppy, and particles also pierce my av which looks dumb. It also means when I give someone else the wings, they still target *me* until they reset all emiters.

THIS IS MY QUESTION:
I have looked and looked for a way to have the child prim emitters (in the wings all linked together) to target a parent prim worn close to my av, but have yet to find it. Is there one?

I've encountered info about UUIDs, but this led to sensors, listening, and all sorts of seemingly overly complex (and confusing) things.
Cid Jacobs
Theoretical Meteorologist
Join date: 18 Jul 2004
Posts: 4,304
10-05-2005 17:14
I think what you may be after is llGetLinkKey() ?
_____________________
Seph DaSilva
Registered User
Join date: 26 Apr 2005
Posts: 27
10-05-2005 17:37
I know I must seem noob, but this worked, and you are awesome :D
Seph DaSilva
Registered User
Join date: 26 Apr 2005
Posts: 27
Erg one more thing
10-05-2005 18:09
Alright this works BUT

I still have to reset each emitter everytime I equip them. As in:
1) wings are fully working, all children shooting particles at same parent.
2) detatch
3) reattatch. all children are shooting themselves for no reason
4) reset particle script on each child and they're back to step 1, all go.

Advice to fix this?
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
10-05-2005 18:24
Put your particle system calls etc. into state_entry and in attach() or on_rez() put a reset script call? I *think* that the attach event won't be called again at that point, but on_rez() is pretty safe I'm sure. (This will also, if you have owner targets, reset the owner every time the wings are rezzed, which is ok for attachments.)

Rerezzing will make new keys, which is probably why they go wrong - their target no longer exists, so you need to make the target tell them what the new key is.

Actually that almost certainly means that putting a link message or similar in that send the target's key through the link set and triggering your particle system from there will also do the job for this particular job.
Seph DaSilva
Registered User
Join date: 26 Apr 2005
Posts: 27
10-05-2005 19:22
I simply can't get it to accept the addition of either an on_rez() section or a llresetscript() tag. I'm afraid I yet prove my ignorance :I

help?
Ushuaia Tokugawa
Nobody of Consequence
Join date: 22 Mar 2005
Posts: 268
10-05-2005 19:38
CODE

default {
on_rez(integer start_param) {
llResetScript();
}

state_entry() {
// call to llParticleSystem
}
}
_____________________
Seph DaSilva
Registered User
Join date: 26 Apr 2005
Posts: 27
10-05-2005 19:54
worked! I was close... missed the semicolon, and also had assumed 'integer start_param' meant for me to fill in an actual integer x.x
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
10-06-2005 03:21
Missing the semi-colon is something you'll rapidly get used to checking back against, irritatingly (although completely understandably) it's the start of the next line where the compiler 'sees' the error - you've just started a new code statement without properly finishing off the last one. It's not the only reason you'll see and error at the start of the line, but for most of us I suspect it's the most common.

The on_rez(integer start_param) line is an event - you can tell that because of the nice blue colour it goes. Some events, like state_entry() don't take arguments, because it's not possible for them to be triggered that way, timer() is another one, it's automatically called at the right time. Some, like listen(integer channel, string name key id, string message) take several.

The arguments have, in simple terms, two functions:

They define local variables (within that event) with those attributes.

They let you test for and manipulate the various things that might fire the event.

For example, the arguments for listen() let you do the filtering in the event for more than one listener (can give you different channels), speaker and set of words, all of which can be useful and at least some of which are probably used in every listen event unless, just maybe you've got a single phrase command as the ONLY thing you want to listen to, in which case it could be done by a well defined listener. In the case of on_rez(integer start_param) it's possibly less used, although if you use the various llRezObject() functions you can pass an integer in there as the start_param, say to define a random channel for listening (you can do other things with it too, but that's one that's quite commonly used).

It's worth noting that because you're defining local variables with those names you can choose what they're called. listen(integer a, string b, key c, string d) compiles just as well as the more long winded one. on_rez(integer num) does too. The names as listed in the wiki and the hover-text help are good because they remind you of what the various things are (which string is which in the listen event for example, which integer is which in the link_message event). They're also good for readability and bug checking you're script. Typing out if(message=="Hello Avatar!";) or similar for a multi-function listener is dull, lots of people use their own abbreviations msg rather than message is a common one, I nearly always use num rather than both start_param and total_number in the relevant events.

Hope this helps with your next project!
bargain Walcott
Registered User
Join date: 31 Oct 2005
Posts: 248
11-15-2005 23:35
I know this may be asking a lot but I have very little knowledge of scripting yet, if any really.

I'm simply trying to get the water in a waterfall script to flow in the direction of an object. I believe the object needs a key so I can tell the script what key to follow.

Well I don't know how to add a key to an object.

Any help is always appreciated.
Gaz Hornpipe
Registered User
Join date: 29 Sep 2005
Posts: 36
11-16-2005 00:28
unless you actually store the value of llDetectedKey(0) in a variable, pass it to the function that handles the particle system or actually make the partilcle system call inside a detection event; there is no way for the particle system to know what key you are talking about. For example:

CODE
start_particles()
{
llParticleSystem([PSYS_PART_FLAGS, PSYS_PART_WIND_MASK |
PSYS_PART_EMISSIVE_MASK,
PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_EXPLODE,
PSYS_PART_START_COLOR, <1,0,0>,
PSYC_SRC_TARGET_KEY,llDetectedKey(0)]);
}

default
{
state_entry()
{
start_particles();
}
}


In the above case, the value of the key returned by the llDetectedKey(0) call will always be a NULL_KEY because it is not called with a detection event. On the other hand...


CODE
key target_key;

start_particles()
{
llParticleSystem([PSYS_PART_FLAGS, PSYS_PART_WIND_MASK |
PSYS_PART_EMISSIVE_MASK,
PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_EXPLODE,
PSYS_PART_START_COLOR, <1,0,0>,
PSYC_SRC_TARGET_KEY,target_key]);
}

default
{
touch_start(integer num_detected)
{
target_key = llDetectedKey(0);
start_particles();
}
}


This will work fine....I hope that clears up the problem with the llDetectedKey() issue you were having at the very least.
bargain Walcott
Registered User
Join date: 31 Oct 2005
Posts: 248
11-16-2005 01:43
Sorry, your way above my head.

Here is the script. I justwant the water to flow in a certain direction. Rather I need a target object or not to do that, I'm not sure.

// Particle System 1.0

StartSteam()
{
// MASK FLAGS: set to "TRUE" to enable
integer glow = TRUE; // Makes the particles glow
integer bounce = FALSE; // Make particles bounce on Z plane of objects
integer interpColor = TRUE; // Color - from start value to end value
integer interpSize = TRUE; // Size - from start value to end value
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; // PSYS_SRC_PATTERN_EXPLODE;

// 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 PARAMETERS

float age = 4.4; // Life of each particle
float maxSpeed = 0.5; // Max speed each particle is spit out at
float minSpeed = 0; // Min speed each particle is spit out at
string texture = "Particle Arrow"; // Texture used for particles, default used if blank
float startAlpha = 0.8; // Start alpha (transparency) value
float endAlpha = 0; // End alpha (transparency) value
vector startColor = <0.75,0.85,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.25,0.25,0.25>; // Start size of particles
vector endSize = <2,10,2>; // End size of particles (if interpSize == TRUE)
vector push = <0.5,0.0,0.0>; // Force pushed on particles

// SYSTEM PARAMETERS

float rate = 0.1; // How fast (rate) to emit particles
float radius = 0.75; // Radius to emit particles for BURST pattern
integer count = 4; // How many particles to emit per BURST
float outerAngle = 3*PI; // Outer angle for all ANGLE patterns PI/4
float innerAngle = 0.5; // 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;


flags = 0;

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_OMEGA, omega,
PSYS_SRC_MAX_AGE, life,
PSYS_SRC_TEXTURE, texture,
PSYS_PART_START_ALPHA, startAlpha,
PSYS_PART_END_ALPHA, endAlpha
]);

}
StartSpray ()
{

}

StopSpray()
{
llParticleSystem([]);
}



default
{
state_entry()
{
StartSteam();
}

listen(integer channel, string name, key id, string message)
{

if (0 == llSubStringIndex(message, "spray on";))
{
StartSteam();

}
else if (0 == llSubStringIndex(message, "spray off";))
{
StopSpray();
}
}
}
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
11-16-2005 06:46
Putting the letters php inside square brackets is the way to set it nicely in here. I think what you want is to put the script below into the target object, and where in your particle script there's the line key target=""; put what the item says between the quotes (so something like key target="5af3450a-0000-0000-00000000" (except it will have less 0's)).

CODE

default
{
state_entry()
{
llSay(0, llGetKey());
}
}


That should give you a message of the target's key (it says it) so you can paste it in to the particle script. This will work as long as you don't rerez the target object - that changes it's key. Minor variations to this script (like an on_rez() event with the same line repeated) or just recompiling it will make it work again.

Good luck, have fun.
bargain Walcott
Registered User
Join date: 31 Oct 2005
Posts: 248
11-16-2005 07:06
Is there an easy way to copy the key # from the chat pop up?

I figured it out, please ignore this.
bargain Walcott
Registered User
Join date: 31 Oct 2005
Posts: 248
11-16-2005 07:14
Awesome, it worked like a charm! Thanks so much. And thanks for the php tip as well, I'll use it next time. I'm just use to forums with the button options to quote things and forgot how to do it the manual way......
Gaz Hornpipe
Registered User
Join date: 29 Sep 2005
Posts: 36
11-16-2005 11:13
From: bargain Walcott
Awesome, it worked like a charm! Thanks so much. And thanks for the php tip as well, I'll use it next time. I'm just use to forums with the button options to quote things and forgot how to do it the manual way......


Since the key for the target prim will change each time you rez the object you will most likely want to do something more along the lines of:

This goes into the Particle Emitter prim of the linkset
CODE
key target_key;
integer target_prim = 1; // The actual number of the child prim's linkset number.
// If you are unsure what it is, you could get it with llGetLinkNumber()
// Once the object is linked, this link number will be constant.

default
{
state_entry()
{
llMessageLinked(target_prim,0,"get key","");
// If no other prims in the linkset have a link_message event, you won't need to
// know the link number, you could just use the LINK_SET constant instead
}

link_message(integer sender, integer number, string command, key id)
{
if(command == "return key")
{
target_key = id;
start_particles(); // start your particles now that you have the correct target key
}
}
}



This goes into the Particle Target prim:
CODE
default
{
link_message(integer sender, integer number, string command, key id)
{
if(command == "get key")
{
llMessageLinked(sender,0,"return key",llGetKey());
}
}
}
Rico Plisskin
Registered User
Join date: 17 Feb 2005
Posts: 104
05-19-2006 10:32
I'm a complete noob to scripting but I keep getting an error at the following section of the Particle Emmiter script from above.

start_particles(); // start your particles now that you have the correct target key

ive been looking for a particle target re-rez script for a while and never had the time to fool around with scripting.