Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llGetLinkKey Particle Target

Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
08-21-2008 17:44
hi, i'm tryin to work out a system of particle based light strings that can be easily changed by a matter of add/removing links.

basically i want the particle system to target the next link in the set, and if it is the last link in the set, obviously, it'll need to target the root. but for the life of me, i can't seem to get it to work. i've even tried sending a link message in the same method providing the link key to the next link to use as the target. but i can't get any of the targeting to work.
i know the adding/removing links thing needs to trigger a change, i got that covered with a changed link even reseting the script. i hope this makes sense. can anyone help? is there a system like this already out there somewhere?

i'm sure it's possble, but until then, i have an interesting curtain of particles to look at lol.
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
08-21-2008 17:59
it's something like this:

integer self = llGetLinkNumber();
integet total = llGetNumberOfPrims();
if (self == total){ targetnum = 1}
if(self <= total){targetnum = self+1}
{llParticleSystem([blahblahblah,
PSYS_TARGET_KEY,llGetLinkKey(targetnum);
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
08-22-2008 12:26
i think i figured out what i did wrong after reading the wiki for it. i don't have the PSYS_PART_TARGET_POS_MASK listed in the flags. i will try it when i get home, hopefully that'll work
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
08-22-2008 12:34
Yep, you can't use PSYS_SRC_TARGET_KEY without setting the PSYS_PART_TARGET_POS_MASK flag, too. Or, rather, you can use it but the SL will just ignore you.

I'm not totally sure I understand what you're doing but be wary of thinking that the link set numbers have anything to do with their positions..
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
08-22-2008 18:47
ok, i got the system working, sort of. the last link isn't targeting the root prim, probably some error in the if statement? should i but the particle system into a different function, and then have both if statements call that function after figuring out which link the script is in?


From: someone

I'm not totally sure I understand what you're doing but be wary of thinking that the link set numbers have anything to do with their positions.

it's kinda hard to explain what i'm talking about i guess. but to see it would be simple. basically i'm stringing lights on a house like christmas lights. i have one prim at each corner of the house. i then link them in the correct order so that i get a "string" of lights from one prim to the next. got that working out fine now that i used the missing flag. except like i said above, the last one isn't targeting the root, just itself
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
08-22-2008 19:23
alright, pretty sure this works now, i guess it was my if statements not right, or instead of target being 1, i changed it to LINK_ROOT. not sure which was wrong, but it's working now lol.

any suggestions, or anything to better the script, lemme know, i'm not an expert scripter by any means, just had an idea and thought i'd try it out, i'm sure someone else out there can do it better.

From: someone

//Particle Light String System 1.0
//Written By Ruthven Willenov
//
//Instructions: Simply Drop this script into a prim, copy the prim however you prefer. Position them appropriately. Then select them backwords in the order you wish the lights to run and link them. The scripts will reset them selves if the number of links change. And that's it! Just sit back and enjoy the lights :-)

integer target;
lightstring()
{
integer self = llGetLinkNumber();
integer totalnum = llGetNumberOfPrims();
if (self <= totalnum)
target = self+1;
if (self == totalnum)
target = LINK_ROOT;

{
llParticleSystem([
PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_DROP,
PSYS_PART_FLAGS,
PSYS_PART_INTERP_COLOR_MASK|//used if you want the colors to change between source and target
PSYS_PART_TARGET_POS_MASK|//Makes the particles more towards the set target, targets itself it no target is set
PSYS_PART_EMISSIVE_MASK|//Makes the particles glow
PSYS_PART_FOLLOW_SRC_MASK|//particles move with the source
PSYS_PART_INTERP_SCALE_MASK,//used if you want the particles to change size between source and target
PSYS_PART_START_SCALE,llGetScale(),//gets the size of the prim the script is is, change if you want to use a different size. IE: PSYS_PART_START_SCALE, <0.1,0.1,0.25>,
PSYS_PART_END_SCALE,llGetScale(),//same as above, must use scale mask in flags above
PSYS_SRC_BURST_RATE,0.01,//how often to emit each burst, in seconds
PSYS_SRC_ACCEL, <0,0,-0.1>,//which direction the particles should move before moving towards target, <0,0,-0.1> makes them move down slightly
PSYS_SRC_BURST_PART_COUNT,2,//how many particles to emit in each burst
PSYS_SRC_TARGET_KEY, (key)llGetLinkKey(target),//get the key of the target link
PSYS_SRC_MAX_AGE, 0.0,//how long to emit particles, in seconds. 0 means forever
PSYS_PART_START_ALPHA, 0.75,//how opaque the particles are when first emitted
PSYS_PART_END_ALPHA, 1.0,//how opaque particles are at the end (must use color mask in flags above)
PSYS_SRC_TEXTURE, "",//uuid for the texture you want the particle to display (or name of texture if it's in the object's inventory)
PSYS_PART_START_COLOR, <1,1,1>,//what color to start the particle with
PSYS_PART_END_COLOR, <1,1,1>//what color to end the particle with(must use color mask in flags above)

]);
}
}

default
{
state_entry()
{
lightstring();
}
changed(integer change)
{
if (change & CHANGED_LINK)//if the number of links changed
llResetScript();//reset this script
}
}