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.