Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: 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
Original Thread
04-25-2005 09:10
/15/a7/3309/1.html
_____________________
i've got nothing. ;)
Dragon Steele
Artist/conservationist
Join date: 3 Jan 2005
Posts: 183
05-18-2005 20:21
What does it do? I have heard of this kind of script but i could never figure out what it does.

thank you

Clueless Dragon
_____________________
Boycot the spam farms and the ads on them. Ban the spamers from your land. Look for the clocktower network for a blacklist to put on you land that is grid wide.
Zalandria Zaius
Registered User
Join date: 17 Jan 2004
Posts: 277
numbers the faces
05-19-2005 07:29
It puts a number on the face of the prim. So if you want to set a texture to a certain side(face) you know which number it is.

Personally I have problems with this script though. Lovely script, but if you use cut prims you can't see the number all the time and if you try to resize or set the offset on the texture you get some other number sliding over.

But it is great for everything except for that.
SteveR Whiplash
teh Monkeh
Join date: 24 Sep 2004
Posts: 173
05-19-2005 09:28
I've used that script a lot, but for the reasons Zalandria mentions, I been using this simple script instead.

Instead of numbering the sides, I decided it was easier if each side was a distinct color. I also put it in touch_start instead of state_entry so you can reset the colors if you make a change to the prim.

CODE

default
{
touch_start(integer num)
{
llSetText("0. Black / 1. White / 2. Red\n3. Blue / 4. Yellow / 5. Green\n6. Orange / 7. Purple / 8. Grey", <1,1,1>, 1.0);

llSetColor(<0,0,0>, 0);
llSetColor(<1,1,1>, 1);
llSetColor(<1,0,0>, 2);
llSetColor(<0,0,1>, 3);
llSetColor(<1,1,0>, 4);
llSetColor(<0,1,0>, 5);
llSetColor(<1,0.5,0>, 6);
llSetColor(<0.5,0,0.5>, 7);
llSetColor(<0.5,0.5,0.5>, 8);
}
}
_____________________
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
05-19-2005 09:39
And for even trickier situations:

CODE


integer i=0;
integer sides=llGetNumberOfSides();

for (i=0;i<sides;i++)
llRotateTexture(i * DEG_TO_RAD,i);



That'll make it so you can select the texture for each side and read off its side number in the "rotation" box. You'll have to clean it up afterwards, of course.
Dragon Steele
Artist/conservationist
Join date: 3 Jan 2005
Posts: 183
05-21-2005 07:41
From: Zalandria Zaius
It puts a number on the face of the prim. So if you want to set a texture to a certain side(face) you know which number it is.

Personally I have problems with this script though. Lovely script, but if you use cut prims you can't see the number all the time and if you try to resize or set the offset on the texture you get some other number sliding over.

But it is great for everything except for that.


AH Thank you. :D
_____________________
Boycot the spam farms and the ads on them. Ban the spamers from your land. Look for the clocktower network for a blacklist to put on you land that is grid wide.