Jump to content

Script help? (Simple problem, but I suck at scripting)`


Jessi Easterman
 Share

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

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

Recommended Posts

Ok, basically, I want to make this script open on a chat command (/678 shirt) instead of on touch. Can anybody give me a hand?

 

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

 

Link to comment
Share on other sites

The simple answer is to take everything that's in the touch_start event now, put a line that says

else if (channel == 678)

before it, and move the entire block into the listen event, after the three lines that say

                llSetTexture(message, ALL_SIDES);             }              }

To complete the exercise, add a state_entry event that says

state_entry(){    llListen(678,"",llGetOwner(),"");}

 There are lots better ways to write a multipage menu system, though, as Ela says.  Take a look at http://community.secondlife.com/t5/LSL-Library/Dynamic-Multi-page-Dialog-AKA-Pagination/td-p/708119, for example.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4600 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...