Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Need a Touch or Voice Command Object Rotate Texture Script

Pendari Lorentz
Senior Member
Join date: 5 Sep 2003
Posts: 4,372
06-29-2004 06:29
Hey there! Ok, I'm not a scriptor. I can change the name for a notecard giver, and I can make a door swing the direction I want it to, and that's about it. hehe.. So I'm not sure how simple this script is that I need, but I am hoping someone could help me out.

I need a script that will basically allow me to touch a prim and have the texture rotate on it. It would be even better if I could have a "voice command" feature where I could tell it which texture to call up (that way if I was on texture one and wanted texture three to show, I could just have it auto pull up texture three).

I need this script for personal use as a tool in my originals auction. This will not be a script I will sell for any reason. I would also of course give the creator full credit if anyone were to ask me about the script.

Can anyone help me please? :)
_____________________
*hugs everyone*
Rysidian Rubio
Ruby Red Head
Join date: 14 Jan 2004
Posts: 263
06-29-2004 07:43
Pendari,

Here is a script that i just wrote that will do what you want. Since SL is down I haven't tested it but it looks that it will work. If you have any problems please IM me (even if I am offline I can reply via email). Hope this is what you are looking for, if not let me know and I can change it.

Just create a new script and cut and paste this in, replacing the standard code in the new script.
CODE

//Change Texture on Click or Command
//By Rysidian Rubio.

//--DESCRIPTION--

//This script will display a texture from the object's inventory onto a face (or faces) of the prim.
//when you click the prim the texture will change to the next texture in the inventory.
//It will also change the texture with voice commands from the owner only, as in instructions.

//--INSTRUCTIONS--

//--You can change textures with voice commands by saying "texture TEXTURENAME" where
//TEXTURENAME is the name of a texture in the object's inventory.
//--You can also change textures by number by saying the number of the texture as so:
//"texturenum NUMBER" where NUMBER is the number of the texture in the object's inventory
//textures are numbered automatically in alphabetical order as they appear in the object's contents.
//--If you say "texture reset" then the textures will be recounted and the first texture will be displayed

//global variables
integer texture_total; //don't change
integer texture_num = 0; //don't change
integer side = 1; //***number of the the side of the prim to show the texture, use ALL_SIDES for all sides of the prim

//function to count textures in inventory
get_textures()
{
texture_total = llGetInventoryNumber(INVENTORY_TEXTURE);
}

//function to reset texture to first texture in inventory
reset_textures()
{
get_textures();
texture_num = 0;
llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, texture_num), side);
}


//function which displays the next texture in the inventory.
next_texture()
{
if (texture_num == texture_total)
{
texture_num = 0;
}
else
{
texture_num += 1;
}
llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, texture_num), side);
}


default {
state_entry()
{
reset_textures();
llListen(0,"",llGetOwner(), "");
}

touch_start(integer total_number)
{
next_texture();
}

changed(integer change)
{
if (change & CHANGED_INVENTORY)
{
reset_textures();
}
}

on_rez(integer start_param)
{
llResetScript();
}

listen(integer channel, string name, key id, string message)
{
if (llToLower(message) == "texture reset")
{
llResetScript();
}
else if (llGetSubString(llToLower(message),0,6) == "texture")
{
string tex = llGetSubString(message,8,-1);
if (llGetInventoryKey(tex) != NULL_KEY)
{
llSetTexture(tex, side);
}
else
{
llSay(0,"Texture not found in object's inventory, please make sure that texture is in inventory and try again");
}
}
else if (llGetSubString(llToLower(message),0,9) == "texturenum")
{
texture_num = (integer)llGetSubString(message, 11,-1);
texture_num -= 1;
llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, texture_num), side);
}
}
}

Pendari Lorentz
Senior Member
Join date: 5 Sep 2003
Posts: 4,372
06-29-2004 09:20
Wonderful!! Thank you so much Rysidian! I'll test this out when I get in world tonight. Thank you again! :D
_____________________
*hugs everyone*