Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Fading out just SPECIFIC prims in a link set - help

Keera Zenovka
Registered User
Join date: 23 Mar 2007
Posts: 35
12-16-2007 18:04
I have 5 prims linked together, with a certain parent prim that I want to remain the parent.

I want to add another 10 child prims to this link set, and I want just THESE 10 to fade out to invisible, and fade in again upon Messagelinked commands. I've got the message linking down fine and it works.

What I don't know how to do is target the new 10 child prims to fade, and leave the original 5 prims alone, including the parent.

Right now I'm testing it out with 1 extra prim added to the linkset, so 6 linked prims all together. I want just this 1 prim to fade in and out. But not only is this 1 prim fading, so are 3 prims from the original link set.

Here's the script in the 1 new fading prim:



float alpha;
float fadespeed = 1.0; //This sets the speed of the fading in and out effect.

integer visible = FALSE;
integer links = 6; //Change this to how many linked objects you have.
integer linknr;
integer thislink;

fadeout()
{
if (visible == TRUE)
{
alpha = llGetAlpha(1)*6;
do
{
++alpha;
do
llSetLinkAlpha(linknr,alpha/6,ALL_SIDES);
while((++linknr)<links);
linknr = thislink;
llSleep(fadespeed);
}
while((integer)alpha<6);
visible = FALSE;
}
}
fadein()
{
if (visible == FALSE)
{
alpha = llGetAlpha(1)*6;
do
{
--alpha;
do
llSetLinkAlpha(linknr,alpha/6,ALL_SIDES);
while((++linknr)<links);
linknr = thislink;
llSleep(fadespeed);
}
while(alpha>0);
visible = TRUE;
}
}

default
{
state_entry()
{
thislink = llGetLinkNumber();
linknr = thislink;
}
link_message(integer sender, integer num, string str, key id)
{
if (str == "hide";)
{
fadeout();

}
if (str == "show";)
{
fadein();
}
}
}
Xhawkx Holden
Registered User
Join date: 1 Nov 2006
Posts: 86
12-16-2007 20:17
only send the hide message to the objects you want to hide, by referencing their link number in the:
llMessageLinked call....

llMessageLinked(integer linknum, integer num, string str, key id);

Sends num, str, and id to members of the link set. The linknum parameter is either the linked number available through llGetLinkNumber or a link constant.

and send the show message to the other ones using linknum
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
12-16-2007 20:36
if only those prims you want contain the fade script then only those will react... or you can place all the scripts in one place and target the links by their link number with set link alpha

now from the way you have it in the script you'd use the first method, (because linknr = current prim) and you only need llSetAlpha...
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
12-16-2007 23:37
Make use of the linkmessage the proper way.
Use the passed integer variable to address the specific scripts.

the event below will only do the fades if the passed integer value is 100. Which eliminates the need to know link numbers or any such thing. Just pass the proper numbers and all prims which are set up for that specific number will react.


link_message(integer sender, integer num, string str, key id)
{
if (100 == num) // reverse order. This will cause an error if 100 = num => cannot assign a variable to a number.
{
if ("hide" == str)
{
fadeout();
}
if ("show" == str)
{
fadein();
}
}
}
Keera Zenovka
Registered User
Join date: 23 Mar 2007
Posts: 35
12-16-2007 23:53
I think I should say that I'm brand new to using llGetLinkNumber (as of today) and still trying to understand how to get it to work properly. The script above is one I found in the forums.

Xhawkx, I want to send both 'hide' and 'show' messages to one and the same prim. Right now that works, but it's dragging 3 other prims along for the ride - they hide and show too, which is not good.

Void, not only do the prims containing the fade script react, but so do 3 other prims that do NOT contain the fade script.....which is what I don't understand. I wish I knew the logic of what is going on there.

I pretty new to this - I hope I'm not trying your patience.
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
12-16-2007 23:58
If you have the script in each prim that should fade then

llSetLinkAlpha(linknr,alpha/6,ALL_SIDES);

should really be

llSetAlpha(alpha/6,ALL_SIDES);

as you want to change the prim that the script is in.
Keera Zenovka
Registered User
Join date: 23 Mar 2007
Posts: 35
12-18-2007 21:51
Squirrel, THANK YOU SO MUCH.

It works!