Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Side Numbering Script

Xylor Baysklef
Scripting Addict
Join date: 4 May 2003
Posts: 109
03-10-2004 18:47
Here is a utility script that I use a lot, so I figured I'd post it for others. Many times in scripting, you have to know what side number a face of a prim is, and this is a quick way to figure that out. It just displays the side number on all sides of the prim.

Best way to use it is to drag a copy of the prim you are working on, throw this script onto it and check the side numbers.

CODE

////////////////////////////////////////////
// Side Numbering Script
//
// Written by Xylor Baysklef
////////////////////////////////////////////

/////////////// CONSTANTS ///////////////////
key NUMBERS_TEXTURE = "fc8df679-ca1b-3ec9-c4ce-b1c832b5b5ce";
///////////// END CONSTANTS /////////////////

///////////// GLOBAL VARIABLES ///////////////
/////////// END GLOBAL VARIABLES /////////////

ShowNumber(integer num, integer face) {
integer Row = num / 10;
integer Col = num % 10;
llOffsetTexture(-0.45 + 0.1 * Col, 0.45 - 0.1 * Row, face);
}

default {
state_entry() {
// Reset rotation, alpha, color and turn off animations.
llRotateTexture(0.0, ALL_SIDES);
llSetAlpha(1.0, ALL_SIDES);
llSetColor(<1, 1, 1>, ALL_SIDES);
llSetTextureAnim(FALSE, 0, 0, 0, 0, 0, 0);

// Show the numbers texture.
llSetTexture(NUMBERS_TEXTURE, ALL_SIDES);
llScaleTexture(0.1, 0.1, ALL_SIDES);

// Go through each side and show a number.
integer i;
for (i = 0; i < llGetNumberOfSides(); i++) {
ShowNumber(i, i);
}
}
}


Xylor
Wednesday Grimm
Ex Libris
Join date: 9 Jan 2003
Posts: 934
07-24-2004 20:45
Here is a quickie modification to number links instead of sides.


CODE

////////////////////////////////////////////
// Link Numbering Script
//
// Written by Xylor Baysklef
// Modified to number links instead of sides by
// Wednesday Grimm
////////////////////////////////////////////

/////////////// CONSTANTS ///////////////////
key NUMBERS_TEXTURE = "fc8df679-ca1b-3ec9-c4ce-b1c832b5b5ce";
///////////// END CONSTANTS /////////////////

///////////// GLOBAL VARIABLES ///////////////
/////////// END GLOBAL VARIABLES /////////////

ShowNumber(integer num, integer face) {
integer Row = num / 10;
integer Col = num % 10;
llOffsetTexture(-0.45 + 0.1 * Col, 0.45 - 0.1 * Row, face);
}

default {
state_entry() {
// Reset rotation, alpha, color and turn off animations.
llRotateTexture(0.0, ALL_SIDES);
llSetAlpha(1.0, ALL_SIDES);
llSetColor(<1, 1, 1>, ALL_SIDES);
llSetTextureAnim(FALSE, 0, 0, 0, 0, 0, 0);

// Show the numbers texture.
llSetTexture(NUMBERS_TEXTURE, ALL_SIDES);
llScaleTexture(0.1, 0.1, ALL_SIDES);

// Show our link number on every side
ShowNumber(llGetLinkNumber(), ALL_SIDES);
}

changed(integer nHow)
{
if (nHow & CHANGED_LINK)
{
ShowNumber(llGetLinkNumber(), ALL_SIDES);
}
}
}
_____________________
Sarcasm meter:
0 |-----------------------*-| 10
Rating: Awww Jeeze!
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
08-25-2004 11:35
I used a script something like this one the other day. When I used it, I was able to get the script to compile fine. When I executed it, I got a message back that said it couldn't find a texture.

Does this script create a numeric image that can be displayed on each side?

If it does, and we have textures already on that object, will the script disturm the existing textured?

I apologize in advance for posting like a newb (even though I am only 24 SL days old at the time of this posting) I still do not recognize some of the function calls, so do not know if I need to have special textures or what...

Thanks for posting this script, it will help me with a project I am working on.
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
Jake Cellardoor
CHM builder
Join date: 27 Mar 2003
Posts: 528
08-28-2004 11:01
The script posted by Xylor specifies the texture by its UUID (the long alphanumeric string in the first non-comment line), so it doesn't need a texture in the object. If your script specified a texture by name, a texture by that name must be in the object's Contents.

The script does replace any textures currently displayed on the object. You'll probably want to create a duplicate of the object you're working on, put the side-numbering script on that, and then refer to it when you work on your own script.