Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

identify faces

Jake Cellardoor
CHM builder
Join date: 27 Mar 2003
Posts: 528
06-23-2003 11:51
This script displays a different number on each face of whatever object it's running on. The number corresponds to the value of the face parameter used by the LSL texture functions to refer to that face.

The attached texture consists of sixteen numbers arranged in four rows of four. The script uses llScaleTexture to enlarge the texture so that just one cell will be displayed on a face. The script then uses llOffsetTexture to locate a specific cell in the texture. The offsets passed to llOffsetTexture are measured from the center of the texture.

The script uses the changed() event handler to reset itself whenever the object is reshaped, so if you change the number of faces of the object (for example, by changing it from a cube to a prism, or by hollowing it out), the numerals displayed are updated automatically.

CODE

display( integer value, integer face )
{
float cell_width = 0.25; // in this example the width
float cell_height = 0.25; // and height are the same

llSetTexture("numbers", face );
llScaleTexture( cell_width, cell_height, face );
if ( value == 0 )
llOffsetTexture( -1.5 * cell_width, 1.5 * cell_height, face );
else if ( value == 1 )
llOffsetTexture( -0.5 * cell_width, 1.5 * cell_height, face );
else if ( value == 2 )
llOffsetTexture( 0.5 * cell_width, 1.5 * cell_height, face );
else if ( value == 3 )
llOffsetTexture( 1.5 * cell_width, 1.5 * cell_height, face );
else if ( value == 4 )
llOffsetTexture( -1.5 * cell_width, 0.5 * cell_height, face );
else if ( value == 5 )
llOffsetTexture( -0.5 * cell_width, 0.5 * cell_height, face );
else if ( value == 6 )
llOffsetTexture( 0.5 * cell_width, 0.5 * cell_height, face );
else if ( value == 7 )
llOffsetTexture( 1.5 * cell_width, 0.5 * cell_height, face );
else if ( value == 8 )
llOffsetTexture( -1.5 * cell_width, -0.5 * cell_height, face );
else if ( value == 9 )
llOffsetTexture( -0.5 * cell_width, -0.5 * cell_height, face );
else if ( value == 10 )
llOffsetTexture( 0.5 * cell_width, -0.5 * cell_height, face );
else if ( value == 11 )
llOffsetTexture( 1.5 * cell_width, -0.5 * cell_height, face );
else if ( value == 12 )
llOffsetTexture( -1.5 * cell_width, -1.5 * cell_height, face );
else if ( value == 13 )
llOffsetTexture( -0.5 * cell_width, -1.5 * cell_height, face );
else if ( value == 14 )
llOffsetTexture( 0.5 * cell_width, -1.5 * cell_height, face );
else if ( value == 15 )
llOffsetTexture( 1.5 * cell_width, -1.5 * cell_height, face );
}

default
{
state_entry()
{
integer i;

for ( i = 0; i < llGetNumberOfSides(); i++ )
display( i, i );
}

changed( integer changed_flag )
{
if ( (changed_flag == CHANGED_SHAPE) ||
(changed_flag == CHANGED_SCALE) )
llResetScript();
}
}


created by jake cellardoor
june
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Thread
04-25-2005 09:10
/54/6a/44203/1.html
_____________________
i've got nothing. ;)