Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Texture change

Chantier Desmoulins
Registered User
Join date: 31 Aug 2005
Posts: 3
08-31-2005 16:02
Hello Scripting Gods,
I used the script for the texture change on voice command, it works great for an object that is one Prim. But if it's say one object 4 Prims it only changes one of the prims to the 'commanded' texture. Is it a problem with the script or the object? I want all four prims in the object to be the new texture, not one part pink and the other three white.
Please help.



integer CHAT_CHANNEL = 5;integer FACE = ALL_SIDES;
default
{
state_entry()
{
llListen(CHAT_CHANNEL, "", llGetOwner(), "";);
}
listen(integer channel, string name, key id, string message)
{
if (llGetInventoryKey(message) != NULL_KEY)
{
llSetTexture(message, FACE);
} else {
integer num = llGetInventoryNumber(INVENTORY_TEXTURE);
integer i;
for (i = 0; i < num; ++i) {
string texture = llGetInventoryName(INVENTORY_TEXTURE, i);
if (texture == message) {
llSetTexture(texture, FACE);
return;
}
}
}
}
}
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
08-31-2005 16:13
Learn to use the PHP tags, and welcome to the scripting forums.

This script was designed to only change one prim's texture, and until we get llSetLinkTexture, you'll need to have slave scripts in the other prims.

By the way, that script has some unnecessary features. llSetTexture will automatically use an inventory texture.

Here's an implementation of what you want:

Master script (In root prim)
CODE

integer CHAT_CHANNEL = 5;
integer FACE = ALL_SIDES;

integer LM_CHANGE_TEXTURE = 34; //Link message integer to change the texture

default
{
state_entry()
{
llListen(CHAT_CHANNEL, "", llGetOwner(), "");
}

listen(integer channel, string name, key id, string msg)
{
llSetTexture( msg, FACE );
llMessageLinked( LINK_SET, LM_CHANGE_TEXTURE, (string)FACE, msg );
}
}


Slave scripts (In other prims)
CODE

integer LM_CHANGE_TEXTURE = 34; //Link message integer to change the texture

default
{
link_message( integer sender, integer num, string str, key id )
{
if ( num == LM_CHANGE_TEXTURE )
llSetTexture( id, (integer)str );
}
}


That should work...
Chantier Desmoulins
Registered User
Join date: 31 Aug 2005
Posts: 3
Texture
09-02-2005 12:22
Well that makes sense, thanks. I'll try it and get right back on here and let everyone know that it worked. :)