Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Library: fader

JJValero Writer
Registered User
Join date: 28 Feb 2007
Posts: 10
08-02-2007 03:09
CODE



integer SIDE = 1;
float INCREMENT = 0.001; // slow
//float INCREMENT = 0.01; // fast


integer g_iTotal;
integer g_iPosition;


makeFader(integer iSide, float fDecremento)
{

vector vColor = llGetColor(iSide);

while((vColor.x > 0.0) && (vColor.y > 0.0) && (vColor.z > 0.0)) {
if (vColor.x > fDecremento) {
vColor.x -= fDecremento;
} else {
vColor.x = 0.0;
} // if

if (vColor.y > fDecremento) {
vColor.y -= fDecremento;
} else {
vColor.y = 0.0;
} // if

if (vColor.z > fDecremento) {
vColor.z -= fDecremento;
} else {
vColor.z = 0.0;
} // if

llSetColor(vColor, iSide);

} // while

} // makeFader

makeUnFader(integer iSide, float fIncremento)
{

vector vColor = llGetColor(iSide);

while((vColor.x < 1.0) && (vColor.y < 1.0) && (vColor.z < 1.0)) {
if (vColor.x < (1.0 - fIncremento)) {
vColor.x += fIncremento;
} else {
vColor.x = 1.0;
} // if

if (vColor.y < (1.0 - fIncremento)) {
vColor.y += fIncremento;
} else {
vColor.y = 1.0;
} // if

if (vColor.z < (1.0 - fIncremento)) {
vColor.z += fIncremento;
} else {
vColor.z = 1.0;
} // if

llSetColor(vColor, iSide);

} // while

} // makeUnFader



default {

state_entry() {

g_iTotal = llGetInventoryNumber(INVENTORY_TEXTURE);
llOwnerSay("Starting ... There are " + (string) g_iTotal + " textures");
g_iPosition = 0;
if (g_iTotal > 0) {
llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, g_iPosition), SIDE);
g_iPosition = (g_iPosition + 1) % g_iTotal;
} // if

} // state_entry

on_rez(integer start_param) {

llResetScript();

} // on_rez

changed(integer change) {

if (change == CHANGED_INVENTORY) {
llResetScript();
} // if

} // changed

touch_start(integer total_number) {

if (g_iTotal > 0) {

makeFader(SIDE, INCREMENT);

llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, g_iPosition), SIDE);
g_iPosition = (g_iPosition + 1) % g_iTotal;

makeUnFader(SIDE, INCREMENT);

// You can use this lines instead makeUnFader()
//vector vColor = <1.0, 1.0, 1.0>;
//llSetColor(vColor, SIDE);

} else {

llOwnerSay("Not found textures in inventary");

} // if

} // touch_start

} // default



Snap Spitteler
Registered User
Join date: 28 Feb 2007
Posts: 5
01-22-2008 06:24
Hi!

This script works nice;)but is it possible to make it so that it goes through the pics automatically?been trying but im not a scripter at all;(
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
01-22-2008 09:26
Instead of the touch_start event, you'll want to use a timer event, and set the period of the timer with llSetTimerEvent().

http://www.lslwiki.net/lslwiki/wakka.php?wakka=llSetTimerEvent
http://www.lslwiki.net/lslwiki/wakka.php?wakka=timer