Don't click here unless you want to be banned.

LSL Wiki : LibraryGeneralMenuEngineExample1

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are ia360925.us.archive.org
This is an example for using the General Menu Engine script.

It is a simple menu system that lets you change parameters of an object.
You get a "main menu" with two submenus, one for changing color (allows selection of Red/Green/Blue) the other for changing size (Normal/double)

The script gets a linkmessage with the MENUID and BUTTONTEXT, eg. "MCOLOR|Red", and it reacts to this.

Instructions:
* Create the "menudefs" notecard, put it in the object
* Put the MenuEngine script into the object (it will read the menudefs upon start/reset, takes a few seconds)
* Put the "Menu Demo" script in the object
* To test: touch the object to access functions and dialogs!

The "menudefs" notecard:
MENU DEFAULT
TEXT Change which parameter of the prim?
TOMENU MCOLOR Color
TOMENU MSIZE Size

MENU MCOLOR
TEXT What color should it be?
OPTION Red
OPTION Green
OPTION Blue

MENU MSIZE
TEXT What size should the prim be?
OPTION Normal
OPTION Double

The Menu demo script:
// Menu demo program

//---Menu Library interface-------------
integer LM_DOMENU   = 10001;
integer LM_OPTIONDATA = 10002;
integer LM_MENULOADED = 10003;
integer LM_RESETMENUSYSTEM = 10004;
integer LM_READSTRING = 10005;
integer LM_READSTRINGDATA = 10006;

resetMenu() {
    llMessageLinked(llGetLinkNumber(),LM_RESETMENUSYSTEM,"",NULL_KEY);    
}
doMenu( key user, string menuname ) {
    llMessageLinked(llGetLinkNumber(),LM_DOMENU,menuname,user);
}
readString( key user, string var, string prompt ) {
    llMessageLinked(llGetLinkNumber(),LM_READSTRING,var+" "+prompt,user);
}
//---Menu Library interface End----------


default
{
    state_entry()
    {   
    }
    
    link_message(integer sender_num, integer num, string str, key id) {
        if (num==LM_OPTIONDATA) {
            // menu result? let's process it!

            if (str=="MCOLOR|Red") llSetColor(<1,0,0>,ALL_SIDES);
            if (str=="MCOLOR|Green") llSetColor(<0,1,0>,ALL_SIDES);
            if (str=="MCOLOR|Blue") llSetColor(<0,0,1>,ALL_SIDES);

            if (str=="MSIZE|Normal") llSetScale(<0.5,0.5,0.5>);
            if (str=="MSIZE|Double") llSetScale(<1,1,1>);
        }
        if (num==LM_MENULOADED) llSay(0,"Menu ready");
    }

    touch_start(integer total_number)
    {
        doMenu(llDetectedKey(0),"DEFAULT");
    }
}
There are 3 comments on this page. [Display comments/form]