FadeEasy

From Second Life Wiki
Revision as of 06:39, 10 September 2009 by Nika Rugani (talk | contribs)
Jump to navigation Jump to search

FadeEasy

Introduction

FadeEasy makes object fading easier for you to make an object fade in or out simply by entering a one line code. Example: llFade(LINK_SET, 0.0, 1.0, ALL_SIDES, 0.05); Or llFade(LINK_SET, 1.0, 0.0, ALL_SIDES, 0.05);


Usage

{Function: llFade(integer linknumber, float AlphaStart, float AlphaEnd, integer faces, float speed); integer linknumber – Link number (0: unlinked, 1: root prim, >1: child prims) or a LINK_* flag float AlphaStart – from 0.0 (clear) to 1.0 (solid), This is the starting opacity of your object float AlphaEnd – from 0.0 (clear) to 1.0 (solid), This is the ending opacity of your object integer faces - LINK_THIS, LINK_ROOT, LINK_SET, LINK_ALL_OTHERS, LINK_ALL_CHILDREN float speed - How much opacity to gain or decrease by }

Function Code

<math> // Leave this part alone! llFade(integer linknumber, float AlphaStart, float AlphaEnd, integer faces, float speed) {

   if(AlphaStart<AlphaEnd)
   {
       for(;AlphaStart<AlphaEnd;)
       {
           AlphaStart+=speed;
           llSetLinkAlpha(linknumber, AlphaStart, faces);
       }
       return;
   }
   else if(AlphaStart>AlphaEnd)
   {
       for(;AlphaStart>AlphaEnd;)
       {
           AlphaStart-=speed;
           llSetLinkAlpha(linknumber, AlphaStart, faces);
       }
       return;
   }

}</math>

Entire Example Code

<math> // Leave this part alone! llFade(integer linknumber, float AlphaStart, float AlphaEnd, integer faces, float speed) {

   if(AlphaStart<AlphaEnd)
   {
       for(;AlphaStart<AlphaEnd;)
       {
           AlphaStart+=speed;
           llSetLinkAlpha(linknumber, AlphaStart, faces);
       }
       return;
   }
   else if(AlphaStart>AlphaEnd)
   {
       for(;AlphaStart>AlphaEnd;)
       {
           AlphaStart-=speed;
           llSetLinkAlpha(linknumber, AlphaStart, faces);
       }
       return;
   }

}

// Global Integer Varibles integer faded;

//==== default {

   on_rez(integer params)
   {
       llFade(LINK_SET, 0.0,1.0,ALL_SIDES,0.05);
       faded = TRUE;
   }
   touch_end(integer num_detected)
   {
       if(faded == TRUE)
       {
           faded = FALSE;
           llFade(LINK_SET, 1.0,0.0, ALL_SIDES, 0.05);
       }
   }

}</math>