Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Smooth fading of a linked set using one script.

Nitrox Peel
Rox
Join date: 12 Jan 2005
Posts: 15
03-20-2007 07:15
Wrote a small code snippet i use to fade in and out the text display on the Rox Media Center.

It basiclly fades out or in a set nr of linked prims using one script.

Learnt alot from this forum so i figured id share it with ya all. And hopefully someone can improve it even more.

CODE

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

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


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

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

}
if (str == "hide")
{
fadein();
}
}
}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Thread
03-21-2007 04:25
/54/d9/172662/1.html
_____________________
i've got nothing. ;)