Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

altering menu driven texture change script to do link prims

Kavar Cleanslate
Registered User
Join date: 18 Nov 2006
Posts: 36
04-21-2008 22:47
I found this script in the library and I was wondering if there is a way to make it work on selected linked prims in this instance hair, coloring several flowers at once.

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);

}
}
}
}
Chatlan Mapholisto
Registered User
Join date: 7 Dec 2007
Posts: 7
04-22-2008 04:55
For copiable textures,
(Thank you Newgate. I've added this part)
replace
llSetTexture(message, ALL_SIDES);
with
llSetLinkTexture(linknumber1, message, ALL_SIDES);
llSetLinkTexture(linknumber2, message, ALL_SIDES);
...
(please replace linknumber1, linknumber2, ... with link numbers of flowers)

For not copiable textures, it will need 2 steps.
1) Replace
llSetTexture(message, ALL_SIDES);
with
llMessageLinked(LINK_SET, 0, message, NULL_KEY);

2) make a script like this
default
{
link_message(integer sender_num, integer num, string str, key id)
{
llSetTexture(str, ALL_SIDES);
}
}
and put this script and textures in the flower prims.

Have fun!
Kavar Cleanslate
Registered User
Join date: 18 Nov 2006
Posts: 36
04-22-2008 08:08
Im getting an error with the second script, im quite a novice do I need to add things to that bit of the script you told me?

From: Chatlan Mapholisto
It needs just 2 steps.

1) Replace
llSetTexture(message, ALL_SIDES);
with
llMessageLinked(LINK_SET, 0, message, NULL_KEY);

2) Make a script which contains
link_message(integer sender_num, integer num, string str, key id)
{
llSetTexture(str, ALL_SIDES);
}
and put it in the prims you want to change the texture.
If you use Textures' names (not UUID) as a message, you also need to put textures in each prim.

Have fun!
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
04-22-2008 13:50
The main limiation of the above approach is that it requires additional scripts in each prim, which equates to additional lag. Try using

llSetLinkTexture

As a brief note the above script requires a default state around the posted code.
_____________________
I'm back......