Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Menu Driven Texture Script - Need Help

Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
08-22-2009 17:05
Andrea, We sometimes get sidetracked. Talarus did make a valid point when it comes to large lists, which this one would be. You would need 17 lists to store all of the texture names. As pointed out, you can also just use an inventory pointer which is what I have done here:

CODE

//////////////////////////////////////////////////////////////////////////////////////////////////////
// TEXTURE MENU
// Version: 1.0
// "Aug 22 2009", "20:02:28"
// Creator: Jesse Barnett
// Released into the Public Domain
//////////////////////////////////////////////////////////////////////////////////////////////////////


integer invCnt;
integer invPntr = 0;
integer mnuChan;
integer mnuHndl;
key tID;
list mnuList;

Dialog() {
invCnt = llGetInventoryNumber(INVENTORY_TEXTURE);
mnuList =[];
if (invPntr < 10) {//Keeps you from using a negative number
invPntr = 0;
}
if (invPntr > invCnt - 10) {//Lets not go past the number of textures in inventory
invPntr = invCnt - 10;
}
if (invPntr > 0) {//only show << if........
mnuList += "<<";
}
integer index = invPntr + 10;
if(invCnt < 10){//Just in case you have a total of less then 10 textures in invetory
index = invCnt;
}
for (; invPntr < index; ++invPntr) {
string invName = llGetInventoryName(INVENTORY_TEXTURE, invPntr);
if(llStringLength(invName) > 24){
llInstantMessage(tID, "Texture Name: " + invName + " is too long."
+ "\nPlease edit and make less then 25 characters long");
//Checks to make sure button names do not exceed 24 characters
return;
}
mnuList += llGetInventoryName(INVENTORY_TEXTURE, invPntr);
}
if (invPntr < invCnt - 10) {//only show >> if.............
mnuList += ">>";
}
llDialog(tID, llDumpList2String(mnuList, "\n"), mnuList, mnuChan);
}

default {
state_entry() {
mnuChan = (integer) llFrand(-1000000) - 1000000;
}
touch_start(integer total_number) {
tID = llDetectedKey(0);
mnuHndl = llListen(mnuChan, "", tID, "");
Dialog();
}
listen(integer channel, string name, key id, string message) {
if (message == ">>") {
Dialog();
}
else if (message == "<<") {
invPntr -= 20;//Go back 20 to end one less then where you were
Dialog();
}
else {
llSetTexture(message, ALL_SIDES);
invPntr -= 10;//You picked a texture. Call same menu page again.
}
}
}

You will notice I also parse the list for the message at the top of the menu. This is in case the texture names are too long for the buttons. The caveat(gotcha) thou is that if your inventory name is longer then 24 characters long, it will throw an error and send a message stating that you need to shorten the name.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Andrea Sage
Registered User
Join date: 18 Oct 2006
Posts: 14
08-22-2009 17:56
Thank you SO much Jesse. I will give this a try!
1 2