Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Another noob scripter question

Patrick Playfair
Registered User
Join date: 19 Jul 2004
Posts: 328
02-20-2005 10:35
I found this example in the wiki library. The directions state that it should be called from an event handler. I have been reading about event handlers, but I guess I am lost. What do i need to do to make this script compile? I get a syntax error at the last bracket.

From: someone
// Call this from an event handler.
// Currently only fades the top.
// Set kSide to ALL_SIDES to fade all sides.

integer kSide = 0;

fade_in_and_out()
{
integer steps = 15;
float base = 0.85;
float delay = 1.0 / steps;
integer i;

// fade up
for (i = 0; i < steps; i++)
{
llSetAlpha(1.0 - llPow(base,i), kSide);
llSleep(delay);
}

llSetAlpha(1.0, kSide);
llSleep(4);

// fade out
for (i = 0; i < steps; i++)
{
llSetAlpha(llPow(base,i), kSide);
llSleep(delay);
}

llSetAlpha(0.0, kSide);
}
_____________________
The meek shall inherit the earth (after I'm through with it).

Patrick Playfair
Cross Lament
Loose-brained Vixen
Join date: 20 Mar 2004
Posts: 1,115
02-20-2005 11:54
Well, what you're looking at is a function (or procedure), not a complete script. You have no default state or any events, so it's not going to compile. :)

Try this (it will make the object face fade in then out each time the object is touched):

CODE
// Call this from an event handler. 
// Currently only fades the top.
// Set kSide to ALL_SIDES to fade all sides.

integer kSide = 0;

fade_in_and_out()
{
integer steps = 15 ;
float base = 0.85 ;
float delay = 1.0 / steps ;
integer i ;

// fade up
for ( i = 0; i < steps; i++ )
{
llSetAlpha( 1.0 - llPow( base, i ), kSide ) ;
llSleep( delay ) ;
}

llSetAlpha( 1.0, kSide ) ;
llSleep( 4 ) ;

// fade out
for ( i = 0; i < steps; i++ )
{
llSetAlpha( llPow( base, i ), kSide ) ;
llSleep( delay ) ;
}

llSetAlpha( 0.0, kSide ) ;
}

default
{
state_entry()
{
}

touch_start( integer num )
{
fade_in_and_out() ;
}
}


No guarantees this will work, as I don't have access to world right now. :)
_____________________
- Making everyone's day just a little more surreal -

Teeple Linden: "OK, where did the tentacled thing go while I was playing with my face?"