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