Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

texture change script need help

Dan Colville
Registered User
Join date: 28 Jul 2006
Posts: 26
09-26-2008 05:11
can someone help me with this. I have a code that when an object is clicked a menu pops up and the user has the option of changing the texture. is there something that i can add so the user can click anywhere on the linked objects so the menu pops up and not just have to click on where the script has been placed.

so say if i was to but the script into the head of a robot can i add something so that i can click on the body (with the same script in that body part) of the robot and still the menu will appear to change the texture of the linked head the script is from the lsl wiki

http://wiki.secondlife.com/wiki/Texture_Menu_Management

///////////////////////////////////////////////////////////////////////////////////////////////////////
list MENU1 = [];
list MENU2 = [];
integer listener;
integer MENU_CHANNEL = 1000;

// opens menu channel and displays dialog
Dialog(key id, list menu)
{
llListenRemove(listener);
listener = llListen(MENU_CHANNEL, "", NULL_KEY, "";);
llDialog(id, "Select one object below: ", menu, MENU_CHANNEL);
}

default
{
on_rez(integer num)
{
// reset scripts on rez
llResetScript();
}

touch_start(integer total_number)
{
integer i = 0;
MENU1 = [];
MENU2 = [];
// count the textures in the prim to see if we need pages
integer c = llGetInventoryNumber(INVENTORY_TEXTURE);
if (c <= 12)
{
for (; i < c; ++i)
MENU1 += llGetInventoryName(INVENTORY_TEXTURE, i);
}
else
{
for (; i < 11; ++i)
MENU1 += llGetInventoryName(INVENTORY_TEXTURE, i);
if(c > 22)
c = 22;
for (; i < c; ++i)
MENU2 += llGetInventoryName(INVENTORY_TEXTURE, i);
MENU1 += ">>";
MENU2 += "<<";
}
// display the dialog
Dialog(llDetectedKey(0), MENU1);
}

listen(integer channel, string name, key id, string message)
{
if (channel == MENU_CHANNEL)
{
llListenRemove(listener);
if (message == ">>";)
{
Dialog(id, MENU2);
}
else if (message == "<<";)
{
Dialog(id, MENU1);
}
else
{
// display the texture from menu selection
llSetTexture(message, ALL_SIDES);

}
}
}
}
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
09-26-2008 05:50
i assume the head is not the root prim. you can find out the linknumber of the head use llSetLinkTexture
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Zhenya Vlodovic
Registered User
Join date: 23 Sep 2008
Posts: 40
09-26-2008 06:02
Are you trying to change the texture in the touched part, or are you trying to change the texture in a particular part no matter where the object is touched?

If you place the touch sensor script in the root prim you can use these functions...

http://wiki.secondlife.com/wiki/Category:LSL_Touch

...to tell more about where the object was touched. Use llSetLinkTexture to set textures of other prims. You'll have to have a loop that reads link names at startup so you know which link number to use. You'll find example code for reading link names here...

http://wiki.secondlife.com/wiki/LlGetLinkName

Do that once at startup and save the linknumber for prims of interest. Don't forget to reset the script on a link change...

http://wiki.secondlife.com/wiki/Changed