Difference between revisions of "GetGlow"

From Second Life Wiki
Jump to navigation Jump to search
m (Edited to update to 2015 formatting.)
 
(15 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==[https://wiki.secondlife.com/wiki/LlGetGlow llGetGlow]==
Since a lot of people have asked, me included, I decided to write a function to compensate for the missing [[llGetGlow|llGetGlow(integer face)]] compliment to [[llGetAlpha|llGetAlpha(integer face)]].


Since a lot of people have asked, me included, I decided to write a function to compensate for the missing [https://wiki.secondlife.com/wiki/LlGetGlow llGetGlow(integer face)] compliment to [https://wiki.secondlife.com/wiki/llGetAlpha llGetAlpha(integer face).]
To this effect, I have reverse engineered the '''llGetAlpha()''' process fairly accurately, and written '''GetGlow()''' to mimic it's functionality to the best of my knowledge.


To this effect, I have reverse engineered the llGetAlpha() process fairly accurately, and written llGetGlow() to mimic it's functionality to the best of my knowledge.
-To date- I have been unable to find a post providing this function. That may be because it is deeply buried far from places where it would be relevantly visible, or, possibly because a function of this design has not been offered before. Either way, Until LSL incorporates an actual [[llGetGlow]]() function, you can use this provision to generate the same effect.  


-To date- I have been unable to find a post providing this function. That may be because it is deeply buried far from places where it would be relevantly visible, or, possibly because a function of this design has not been offered before. Either way, Until LSL incorporates an actual llGetGlow() function, you can use this provision to generate the same effect.  
I submit for your convenience, a functional equivalent to [[llGetGlow]]().


I submit for your convenience, a functional equivalent to llGetGlow().
Place the following function at the top of each script you wish to use '''GetGlow(integer face)''' within.
 
<syntaxhighlight lang="lsl2">
Place the following function at the top of each script you wish to use llGetGlow(integer face) within.
float GetGlow(integer i){ // This function is similar to llGetAlpha(). Usage: float GetGlow(integer face)
<lsl>
     if(i > llGetNumberOfSides()){ return FALSE; }
float llGetGlow(integer ia){// This function is similar to llGetAlpha(). Usage: float llGetGlow(integer face)
     if(ia > llGetNumberOfSides()) { return TRUE; }
     else{
     else{
         list la = llGetPrimitiveParams([PRIM_GLOW, ia]);
        float f;
         float fa;
         list l = llGetPrimitiveParams([PRIM_GLOW, i]);
        for(ia = llGetListLength(la); ia > -1; ia--)fa += llList2Float(la, ia);
         i = llGetListLength(l);
         return fa;     
        do{f+=llList2Float(l,i);}while(i--);
         return f;     
         }
         }
}
}</syntaxhighlight>
</lsl>''Function float llGetGlow(integer face) by -ThumpieBunnyEve Hax''
''Function float GetGlow(integer face) by -ThumpieBunnyEve Hax''


Here is the Equivalent LSL Portal page formatting for use with it.   
Here is the Equivalent LSL Portal page formatting for use with it.   


<h1>[https://wiki.secondlife.com/wiki/float float] llGetGlow([https://wiki.secondlife.com/wiki/integer integer] face)</h1>
<h1>[[float]] GetGlow([[integer]] face)</h1>


[https://wiki.secondlife.com/wiki/return Returns] the [https://wiki.secondlife.com/wiki/glow Glow] (intensity) of the given [https://wiki.secondlife.com/wiki/face face].
[[Return]]s the [[Glow]] (intensity) of the given face.


If face is [https://wiki.secondlife.com/wiki/constants ALL_SIDES], the [https://wiki.secondlife.com/wiki/value value] returned is the sum of glows on all faces. To obtain the mean value, use the following:
If face is [[ALL_SIDES]], the value returned is the sum of glows on all faces. To obtain the mean value, use the following:
<lsl>float meanGlow = llGetGlow(ALL_SIDES) / ((float)llGetNumberOfSides());</lsl>
<syntaxhighlight lang="lsl2">float meanGlow = GetGlow(ALL_SIDES) / ((float)llGetNumberOfSides());</syntaxhighlight>




Line 35: Line 34:


Verbosely commented Example:
Verbosely commented Example:
<lsl>
<syntaxhighlight lang="lsl2">
//Blackbox Tech Revealed!  Usage: float llGetGlow(integer face)
//Blackbox Tech Revealed!  Usage: float GetGlow(integer face)
float llGetGlow(integer ia){// This function is similar in many if not all capacities to llGetAlpha();
float GetGlow(integer i)// This function is similar in many if not all capacities to llGetAlpha();
if(ia > llGetNumberOfSides()) {//To note: I have no idea why llGetAlpha returns the value TRUE
{
  return TRUE;                //-when we ask for a side > GetNumberOfSides,  
    if(i > llGetNumberOfSides()) //To note: I'm not sure why llGetAlpha returns the value TRUE for non existent sides,
  }                          //but I've reproduced the effect here in llGetGlow for continuity.
        {                        //but I'm going to assume that it's relevant to the way the Clients editor-
        return FALSE;            //adds sides when you alter a prims properties.  
        }                         
                                                
                                                
                                             
    else
else{
        {
    list la = llGetPrimitiveParams([PRIM_GLOW, ia]);//This list may contain floats derived from multiple sides if (ia) is Negitive,  
        float f; //memory space for the addition of float data derived from (l) below.
                                                    //a single side if (ia) Positive, or no sides if (ia) > llGetNumberOfSides().
        list l = llGetPrimitiveParams([PRIM_GLOW, i]);//This list may contain floats derived from multiple sides if (i) is Negitive,  
 
                                                        //a single side if (i) Positive, or no sides if (i) > llGetNumberOfSides().
    float fa; //memory space for the addition of float data derived from (la) below.
        i = llGetListLength(l);//To save memory space, we'll reuse integer (i), assigning it the # of Sides passed to this function.
    for(ia = llGetListLength(la); ia > -1; ia--){//To save memory space, we'll reuse integer ia, assigning it the # of Sides.
         do{f+=llList2Float(l,i);}while(i--); //Here we loop through the # of Sides, adding each glow value to the float (f).
         fa += llList2Float(la, ia);//add together all available floats from list (la)
        return f;   //finally we return the cumulative glow total of (i)'s side(s).
         }
         }
    return fa;//return the cumulative glow total of (ia)'s side(s).
    }
}
}


//---Below is an example of LLGetGlow's usage, and it's Comparison to llGetAlpha.---
//---Below is an example of GetGlow's usage, and it's Comparison to llGetAlpha.---


default
default
Line 62: Line 61:
             llSetPrimitiveParams([PRIM_COLOR, -1, <0,0,1>, .5,PRIM_GLOW,-1,.5]);
             llSetPrimitiveParams([PRIM_COLOR, -1, <0,0,1>, .5,PRIM_GLOW,-1,.5]);
             llOwnerSay(" \n"+
             llOwnerSay(" \n"+
             "llGetGlow(ALL_SIDES)= " +(string)llGetGlow(ALL_SIDES)+"\n"+
             "GetGlow(ALL_SIDES)= " +(string)GetGlow(ALL_SIDES)+"\n"+
             "llGetAlpha(ALL_SIDES)= "+(string)llGetAlpha(ALL_SIDES)+"\n"+
             "llGetAlpha(ALL_SIDES)= "+(string)llGetAlpha(ALL_SIDES)+"\n"+
             "llGetGlow(-1)= " +(string)llGetGlow(-1) +"\n"+
             "GetGlow(-1)= " +(string)GetGlow(-1) +"\n"+
             "llGetAlpha(-1)= "+(string)llGetAlpha(-1)+"\n"+
             "llGetAlpha(-1)= "+(string)llGetAlpha(-1)+"\n"+
             "llGetGlow(2)= "  +(string)llGetGlow(2)  +"\n"+
             "GetGlow(2)= "  +(string)GetGlow(2)  +"\n"+
             "llGetAlpha(2)= " +(string)llGetAlpha(2) +"\n"+
             "llGetAlpha(2)= " +(string)llGetAlpha(2) +"\n"+
             "llGetGlow(0)= "  +(string)llGetGlow(0)  +"\n"+
             "GetGlow(0)= "  +(string)GetGlow(0)  +"\n"+
             "llGetAlpha(0)= " +(string)llGetAlpha(0) +"\n"+
             "llGetAlpha(0)= " +(string)llGetAlpha(0) +"\n"+
             "llGetGlow(25)= " +(string)llGetGlow(25) +"\n"+
             "GetGlow(25)= " +(string)GetGlow(25) +"\n"+
             "llGetAlpha(25)= "+(string)llGetAlpha(25));
             "llGetAlpha(25)= "+(string)llGetAlpha(25));
             }
             }
}
}
</lsl>''Example of usage by -ThumpieBunnyEve Hax''
</syntaxhighlight>''Example of usage by -ThumpieBunnyEve Hax''




Line 80: Line 79:
<code><br>
<code><br>
To Owner:<br>
To Owner:<br>
llGetGlow(ALL_SIDES)= 3.000000<br>
GetGlow(ALL_SIDES)= 3.000000<br>
llGetAlpha(ALL_SIDES)= 3.000000<br>
llGetAlpha(ALL_SIDES)= 3.000000<br>
llGetGlow(-1)= 3.000000<br>
GetGlow(-1)= 3.000000<br>
llGetAlpha(-1)= 3.000000<br>
llGetAlpha(-1)= 3.000000<br>
llGetGlow(2)= 0.500000<br>
GetGlow(2)= 0.500000<br>
llGetAlpha(2)= 0.500000<br>
llGetAlpha(2)= 0.500000<br>
llGetGlow(0)= 0.500000<br>
GetGlow(0)= 0.500000<br>
llGetAlpha(0)= 0.500000<br>
llGetAlpha(0)= 0.500000<br>
llGetGlow(25)= 1.000000<br>
GetGlow(25)= 0.000000<br>
llGetAlpha(25)= 1.000000<br>
llGetAlpha(25)= 1.000000<br>
</code>
</code>

Latest revision as of 00:02, 3 March 2015

Since a lot of people have asked, me included, I decided to write a function to compensate for the missing llGetGlow(integer face) compliment to llGetAlpha(integer face).

To this effect, I have reverse engineered the llGetAlpha() process fairly accurately, and written GetGlow() to mimic it's functionality to the best of my knowledge.

-To date- I have been unable to find a post providing this function. That may be because it is deeply buried far from places where it would be relevantly visible, or, possibly because a function of this design has not been offered before. Either way, Until LSL incorporates an actual llGetGlow() function, you can use this provision to generate the same effect.

I submit for your convenience, a functional equivalent to llGetGlow().

Place the following function at the top of each script you wish to use GetGlow(integer face) within.

float GetGlow(integer i){ // This function is similar to llGetAlpha(). Usage: float GetGlow(integer face)
    if(i > llGetNumberOfSides()){ return FALSE; }
    else{
        float f;
        list l = llGetPrimitiveParams([PRIM_GLOW, i]);
        i = llGetListLength(l);
        do{f+=llList2Float(l,i);}while(i--);
        return f;    
        }
}

Function float GetGlow(integer face) by -ThumpieBunnyEve Hax

Here is the Equivalent LSL Portal page formatting for use with it.

float GetGlow(integer face)

Returns the Glow (intensity) of the given face.

If face is ALL_SIDES, the value returned is the sum of glows on all faces. To obtain the mean value, use the following:

float meanGlow = GetGlow(ALL_SIDES) / ((float)llGetNumberOfSides());



Verbosely commented Example:

//Blackbox Tech Revealed!  Usage: float GetGlow(integer face)
float GetGlow(integer i)// This function is similar in many if not all capacities to llGetAlpha();
{
    if(i > llGetNumberOfSides()) //To note: I'm not sure why llGetAlpha returns the value TRUE for non existent sides,
        {                         //but I'm going to assume that it's relevant to the way the Clients editor-
        return FALSE;             //adds sides when you alter a prims properties. 
        }                          
                                               
    else
        {
        float f; //memory space for the addition of float data derived from (l) below.
        list l = llGetPrimitiveParams([PRIM_GLOW, i]);//This list may contain floats derived from multiple sides if (i) is Negitive, 
                                                        //a single side if (i) Positive, or no sides if (i) > llGetNumberOfSides().
        i = llGetListLength(l);//To save memory space, we'll reuse integer (i), assigning it the # of Sides passed to this function.
        do{f+=llList2Float(l,i);}while(i--); //Here we loop through the # of Sides, adding each glow value to the float (f).
        return f;    //finally we return the cumulative glow total of (i)'s side(s).
        }
}

//---Below is an example of GetGlow's usage, and it's Comparison to llGetAlpha.---

default
{
state_entry(){
             llSetPrimitiveParams([PRIM_COLOR, -1, <0,0,1>, .5,PRIM_GLOW,-1,.5]);
             llOwnerSay(" \n"+
             "GetGlow(ALL_SIDES)= " +(string)GetGlow(ALL_SIDES)+"\n"+
             "llGetAlpha(ALL_SIDES)= "+(string)llGetAlpha(ALL_SIDES)+"\n"+
             "GetGlow(-1)= " +(string)GetGlow(-1) +"\n"+
             "llGetAlpha(-1)= "+(string)llGetAlpha(-1)+"\n"+
             "GetGlow(2)= "  +(string)GetGlow(2)  +"\n"+
             "llGetAlpha(2)= " +(string)llGetAlpha(2) +"\n"+
             "GetGlow(0)= "  +(string)GetGlow(0)  +"\n"+
             "llGetAlpha(0)= " +(string)llGetAlpha(0) +"\n"+
             "GetGlow(25)= " +(string)GetGlow(25) +"\n"+
             "llGetAlpha(25)= "+(string)llGetAlpha(25));
             }
}

Example of usage by -ThumpieBunnyEve Hax


Example output of the script above.
To Owner:
GetGlow(ALL_SIDES)= 3.000000
llGetAlpha(ALL_SIDES)= 3.000000
GetGlow(-1)= 3.000000
llGetAlpha(-1)= 3.000000
GetGlow(2)= 0.500000
llGetAlpha(2)= 0.500000
GetGlow(0)= 0.500000
llGetAlpha(0)= 0.500000
GetGlow(25)= 0.000000
llGetAlpha(25)= 1.000000


Sorry if the Formatting is off, I could really use some help making this page look more professional, This is my first provisionary page. Edits and corrections welcome, but especially page formatting assistance! -ThumpieBunnyEve Hax