Jump to content

24 character dialog menu error


Moni Telling
 Share

You are about to reply to a thread that has been inactive for 1169 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I have an multi give object dialog menu.

Menu recognize names in contents of prim and convert names to a button

The problem is if the names are too long I get  an 24 character error

How can I shorten names on button but still give item when recognize full name to give item on the button?

 

HERE IS THE  SCRIPT

 

list object_list;
list object_list2;
key user = NULL_KEY;

composelist()
{
    integer currentobject = 0;
    integer totalobjects = llGetInventoryNumber(INVENTORY_OBJECT);
   
    if(totalobjects > 0 & totalobjects <= 12)
    {
        object_list = [];
        do
        {
            object_list = object_list + llGetInventoryName(INVENTORY_OBJECT, currentobject);
            currentobject++;
        }
        while (currentobject > 0 & currentobject < totalobjects);
    }
   
    if(totalobjects > 12 & totalobjects <= 22)
    {
        object_list = ["Next Page"];
        do
        {
            object_list = object_list + llGetInventoryName(INVENTORY_OBJECT, currentobject);
            currentobject++;
        }
        while (currentobject > 0 & currentobject < 11);
       
        object_list2 = ["Last Page"];
        do
        {
            object_list2 = object_list2 + llGetInventoryName(INVENTORY_OBJECT, currentobject);
            currentobject++;
        }
        while (currentobject >= 11 & currentobject < totalobjects);
    }
   
    if(totalobjects > 22)
    {
        llWhisper(0, "You may only have a maximimum of 22 Objects. Please remove any extra ones.");
    }
    if(totalobjects == 0)
    {
        llWhisper(0, "Please add up to 22 Objects to give away. They should be Copy/Transfer.");
    }
}


//The Menu
integer menu_handler;
integer menu_channel;
menu(key user,string title,list object_list)
{
    menu_channel = (integer)(llFrand(99999.0) * -1); //random channel
    menu_handler = llListen(menu_channel,"","","");
    llDialog(user,title,object_list,menu_channel);
    llSetTimerEvent(30.0); //menu channel open for 30 seconds
}

default
{
    state_entry()
    {
        composelist(); //make list from inventory objects
    }

    touch_start(integer total_number)
    {
        user = llDetectedKey(0);
        if (user == llGetOwner())
        {
            menu(user,"\n\nPlease select one below.",object_list);
        }
        else
        {
            llInstantMessage(user,"These items are for the owner only, sorry.");
        }
    }
   
    listen(integer channel,string name,key id,string message)
    {
        if (channel == menu_channel)
        {           
            if(message == "Next Page")
            {
                menu(user,"\n\nPlease select one below.",object_list2);
            }
            else if(message == "Last Page")
            {
                menu(user,"\n\nPlease select one below.",object_list);
            }
            else
            {
                llGiveInventory(user,message); //Give Object
                llSetTimerEvent(0.0);
                llListenRemove(menu_handler);
            }
        }
    }
   
    timer() //Close the Menu Listen or we'll get laggy
    {
        llSetTimerEvent(0.0);
        llListenRemove(menu_handler);
    }
   
    changed(integer change)
    {
        if (change & CHANGED_INVENTORY) //inventory has changed
        {
            llSleep(0.5);
            composelist(); //rebuild the list
        }
    }
}

Link to comment
Share on other sites

You have a couple of choices:

1. Save a shortened name, maybe by just cutting off any characters after the 24th one.

2. Save the names in a numbered list, display them in the dialog text, and refer to them by numbered buttons.

Both methods work well.

Edited by Rolig Loon
Link to comment
Share on other sites

3 minutes ago, Moni Telling said:

i tried that it semi worked but when I click the button it doesn't recognize the item to give

Shortening the name?  Well, you do need to use the shortened name as a test. So, for example, if you had created name from

name = llGetSubString( llGetInventoryName( INVENTORY_OBJECT, 0 ), 0, 12 );

Then you would have your listen event study the message from your dialog and apply a test:

if (message == name)

{

    llGiveInventory(ThatAv, llGetInventoryName( INVENTORY_OBJECT, 0 ) );

}

Since name is created from llGetInventoryName( INVENTORY_OBJECT, 0 ) , that test will always give the correct object.

Link to comment
Share on other sites

I got this far with the menu button it worked. now it doesn't  recognize the item to give

 

 

 

composelist()
{
    integer currentobject = 0;
    integer totalobjects = llGetInventoryNumber(INVENTORY_OBJECT);
  
    if(totalobjects > 0 & totalobjects <= 12)
    {
        object_list = [];
        do
        {
            string name = llGetInventoryName(INVENTORY_OBJECT, currentobject);
            sub = llGetSubString(name, 0, 12);
            object_list = object_list + sub;
            currentobject++;
        }
        while (currentobject > 0 & currentobject < totalobjects);
    }
  
    if(totalobjects > 12 & totalobjects <= 22)
    {
        object_list = ["Next Page"];
        do
        {
            string name = llGetInventoryName(INVENTORY_OBJECT, currentobject);
            sub = llGetSubString(name, 0, 12);
            object_list = object_list + sub;
            currentobject++;
        }

Link to comment
Share on other sites

Moni, this script requires a substantial rewrite to resolve the issue of long button names

given your level of scripting skills at this time, rather than trying to rewrite this script you would be better off asking in Wanted sub-forum for a script that handles this already. Of which there are many

 

Link to comment
Share on other sites

Rolig already directed you in the right direction in the link above. Dialog Choices from Numbered Buttons

which is the right way to do this

hacking the script you have is not the right way to do it

ps edit.  "not the right way" means sub-optimal. Sub-optimal is not what we want to be doing in our scripts

 

Edited by Mollymews
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1169 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...