Jump to content

Data menu


2toe Bigboots
 Share

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

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

Recommended Posts

Wanna catagorize my animations by notecard as such

!=cat1

@=cat2

this way i can add more catigorys latter or change cat names

wanna click object to show main menu click the catigory im looking for show the page there on or call only thouse how ever that would work. im close just need help. Be nice i know its messy right now lol.

 

string Config;
integer cAllowed = 0;
//integer handle;
key CHTSQueryID;
//string mess;

list categories =[];

integer mAPI_items_number;
integer mAPI_last_page_items;
integer mAPI_page = -1;                                      // must be set to -1
integer mAPI_pages_number;
//integer i;
//----------------------------
// This wrapper's output is a list to directly input in llDialog() for
// the from top to bottom alphabetical display of menu buttons.

list mAPI_SetButtons(list menu_items)
{
    if(mAPI_page == -1)
        mAPI_GetPagesNumber(menu_items, llGetListLength(menu_items));
    if(mAPI_items_number < 12)
        return mAPI_SetButtonsSinglePage(llListSort(menu_items, 1, TRUE));
    else
        return mAPI_SetButtonsMultPages(llListSort(menu_items, 1, TRUE));
}

list mAPI_SetCatButtons(list menu_items)
{
    if(mAPI_page == -1)
        mAPI_GetPagesNumber(menu_items, llGetListLength(menu_items));
    if(mAPI_items_number < 12)
        return mAPI_SetButtonsSinglePage(llListSort(menu_items, 1, TRUE));
    else
        return mAPI_SetButtonsMultPages(llListSort(menu_items, 1, TRUE));
}

//----------------------------
mAPI_GetPagesNumber(list src, integer src_len)
{
    mAPI_items_number = src_len;
    if(src_len > 11)
    {
        mAPI_pages_number = src_len / 9;
        mAPI_last_page_items = src_len % 9;
        if(mAPI_last_page_items != 0) mAPI_pages_number++;
        else mAPI_last_page_items = 9;
    }
    else
    {
        mAPI_pages_number = 1;
        mAPI_last_page_items = src_len;
    }
    mAPI_page = 1;
}

//----------------------------
// This function will arrange up to 9 menu buttons in alphabetical order from the top left to the bottom
// right for display by llDialog() function. The buttons arrangement in llDialog() is
//  9 10 11
//  6  7  8
//  3  4  5
// [0  1  2]
// There are only 3 top rows available because the bottom row is taken by '<==', 'auto', '==>' buttons.
// The input list is alphabetically sorted so all we need to do is to rearrange the list from
// [a,b,c,d,e,f,g,h,i] to [g,h,i,c,d,e,a,b,c], considering of course that the input list may contain
// less than 9 elements, which is most often than not will be the case for the last page.

list mAPI_SetButtonsMultPages(list src)
{
    list wlist;
    list page_src;
    list dest;
    list auto = ["<==", "Exit", "==>"];
    list matrix = [ 0,1,2,0,1,2,0,1,2];
    integer first;
    integer last;
    integer i;
    integer items = 9;

    if(mAPI_page > mAPI_pages_number) mAPI_page = 1;
    else if(mAPI_page == 0) mAPI_page = mAPI_pages_number;

    first = (mAPI_page - 1) * 9;                         // 0, 9, 18, etc
    last = mAPI_page * 9 - 1;                            // 8, 16, 24, etc
    page_src=llList2List(src, first, last);

    if(mAPI_page == mAPI_pages_number)
    {
        items = mAPI_last_page_items;
        if(mAPI_last_page_items % 3 == 1)                  //  7, 4 ,1
            matrix = llDeleteSubList(matrix,1,2);
        else if(mAPI_last_page_items % 3 == 2)             //  8, 5, 2
            matrix = llDeleteSubList(matrix,2,2);
    }
    for(i=0; i< items; i++)
    {
        wlist = llList2List(page_src, i, i);
        dest = llListInsertList(dest, wlist, llList2Integer(matrix, i));
    }
    dest = llListInsertList(dest, auto, 0);
    return dest;
}

//----------------------------
// This function will arrange up to 11 menu buttons in alphabetical order from the top left to the bottom
// right for display by llDialog() function. The buttons arrangement in llDialog() is
//  9 10 11
//  6  7  8
//  3  4  5
//  0  1 [2]
// Position # 2 is taken by 'auto' button.
// The input list is alphabetically sorted so all we need to do is to rearrange the list from
// [a,b,c,d,e,f,g,h,i,j,k] to [i,j,k f,g,h,c,d,e,a,b,'auto'], considering of course that the input
// list may contain less than 11 elements.

list mAPI_SetButtonsSinglePage(list src)
{
    list wlist;
    list dest;
    list auto = ["Exit"];
    list matrix = [ 0,1,2,0,1,2,0,1,2,0,1];
    integer i;

    if(mAPI_last_page_items % 3 == 1)                   // 10, 7, 4 ,1
        matrix = llDeleteSubList(matrix,2,2);
    else if(mAPI_last_page_items % 3 == 0)              //  9, 6, 3
        matrix = llDeleteSubList(matrix,1,2);

    for(i=0; i< mAPI_last_page_items; i++)
    {
        wlist = llList2List(src, i, i);
        dest = llListInsertList(dest, wlist, llList2Integer(matrix, i));
    }
    dest = llListInsertList(dest, auto, 2);
    return dest;
}

// API CODE END
//==============================
// USAGE SAMPLE START
// This sample will make a menu of contents of a prim the script is in.
// It will not include itself in the menu.
// The script illustrates menu making not menu processing so it does nothing
// on a button click other than an arrow. That's for you to code yourself.

float   MENU_TIMEOUT = 30.0;
list    inventory_items;
integer lhandle;

//------------------------------
// user function, not a part of the mAPI
MakeMenu(key id)
{
    list menu;
    string mtext = "Prim Content:\nPage ";
    integer mchan;

    menu = mAPI_SetButtons(inventory_items);                   // call mAPI to make alphabetical menu list
    while(!mchan) mchan = -llFloor(llFrand(2000000));          // make some random channel, less lag with negative channels
    mtext += (string)mAPI_page + " of " + (string)mAPI_pages_number + "   " + (string)llGetInventoryNumber(INVENTORY_ANIMATION) + "   " + "Animations found";
    llSetTimerEvent(MENU_TIMEOUT);
    lhandle = llListen(mchan, "", id, "");                     // listen on sending channel
    llDialog(id, mtext, menu, mchan);                          // send menu
}

MakeCatMenu(key id)
{
    list menu;
    string mtext = "Prim Content:\nPage ";
    integer mchan;

    menu = mAPI_SetButtons(Config);                   // call mAPI to make alphabetical menu list
    while(!mchan) mchan = -llFloor(llFrand(2000000));          // make some random channel, less lag with negative channels
    mtext += (string)mAPI_page + " of " + (string)mAPI_pages_number + "   " + (string)llGetInventoryNumber(INVENTORY_ANIMATION) + "   " + "Animations found";
    llSetTimerEvent(MENU_TIMEOUT);
    lhandle = llListen(mchan, "", id, "");                     // listen on sending channel
    llDialog(id, mtext, menu, mchan);                          // send menu
}
//list Panim;
//------------------------------
default
{
	state_entry()
	{

		Config = llGetInventoryName(INVENTORY_NOTECARD,0);
		string iname;
		integer n = llGetInventoryNumber(INVENTORY_ANIMATION);
		integer i;
		categories = [(string)llGetSubString(llGetNotecardLine(Config,0),0,10)];
		for(i=0; i<n; i++)
		{
			iname = llGetInventoryName(INVENTORY_ANIMATION, i);
			if(iname != llGetScriptName())
				inventory_items += [llGetInventoryName(INVENTORY_ANIMATION,0)];    //a menu button cannot have text longer than 24 chars
		}
		if(n > 0) llSay(0, "Content list completed. Touch for menu");
		else llSay(0, "There is no content");
	}

	on_rez(integer param)
	{
		llResetScript();
	}
	attach(key attached)
	{
		llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
		llSetText("",<0.0,0.0,0.0>,1.0);
	}

	changed(integer change)
	{
		if(change & CHANGED_INVENTORY)
		{
			llSay(0, "Inventory change detected. Loading New Gesture");
			llResetScript();
		}
	}

	listen(integer ch, string name, key id, string mes)
	{
		list src=llGetNotecardLine(Config,0);
		list cat = llSubStringIndex(src,categories);
		list anims = llGetAnimationList( llGetOwner() );
		//string wstr;
		string iname;
		iname = llGetInventoryName(INVENTORY_ANIMATION, 0);

		llSetTimerEvent(0.0);
		llListenRemove(lhandle);
		if(mes == "<==")                                       // previous page
		{
			--mAPI_page;
			MakeMenu(id);
		}
		else if(mes == "==>")                                  // next page
		{
			++mAPI_page;
			MakeMenu(id);
		}
		else if(mes == "Exit")
		{
			integer n;
			for ( n=0; n<llGetListLength( anims ) ;n++ )

				llStopAnimation( llList2String( anims,n ));
			llSetText("",<0.0,0.0,0.0>,1.0);
			llSleep(0.2);
		}
		else if(mess == src);
	{
		--mApi_page;
		MakeCatMenu(llGetOwner());
	}
		timer()
		{
			llSetTimerEvent(0.0);
			llListenRemove(lhandle);
		}
				touch_start(integer total_num)
		{
			llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
			if(llDetectedKey(0) == llGetOwner())
				MakeCatMenu(llGetOwner());
		}
		dataserver(key requested, string data)
		{
			if    (requested == CHTSQueryID) {
				if (data != EOF) {    // not at the end of the notecard
					categories = (string)[data] + categories;
					++cAllowed;                // increase line count
					CHTSQueryID = llGetNotecardLine(Config, cAllowed);
				}
			}
		}
}

 

Link to comment
Share on other sites

If you would care to explain your requirements more fully, more clearly and in English we may be able to help you more effectively.  You may well find that explaining exactly what the problem is - such as, for instance, telling us what isn't working at the moment - helps to clarify things in your own mind as well, helping you to solve your own problems.

Here are a few things we have to guess as you don't make them clear:

  • !=cat1/@=cat2 - what is that meant to mean?  You'll list your animations on a notecard annotated with '!',  '@' and other, to be decided, marks?
  • change cat names - my cat was called 'Reg' because he was a 'D-registration' cat (cars at the time I got him) and I couldn't think of a better name.  Are you now saying you'll have a list of category names on a notecard and rename animations in contents?  Or both categories and animations listed on notecard, or what?
  • click object to show main menu - 'the object with the script' I assume, but what menu?  What main menu
  • click the category - In the menu?  Does that mean the main menu is meant to be of categories?  Read from the notecard?
  • show the page there on - Page?  There on?  Does not parse
  • call only [those] - Call what?

Now it's possible that if I read all the script - thank you for posting it, at least - and experiment for an hour or so in-world, that I might be able to guess what you're trying to do and then guess how you'd like to do it, but that's a bit too much 'might', 'guess' and 'hard work'

Link to comment
Share on other sites

I adopt Peter's comments.  

However, I did notice several things that are clearly wrong in the code -- 

for(i=0; i<n; i++)		{			iname = llGetInventoryName(INVENTORY_ANIMATION, i);			if(iname != llGetScriptName())				inventory_items += [llGetInventoryName(INVENTORY_ANIMATION,0)];    //a menu button cannot have text longer than 24 chars		}

 won't work.  Try

 

for(i=0; i<n; i++)		{			iname = llGetInventoryName(INVENTORY_ANIMATION, i);			//if(iname != llGetScriptName()) llGetScriptName can't possibly be an animation			inventory_items += [llGetSubString(iname,0,23)];//your comment suggests you want to shorten the name of the animation					}

 and I don't understand what is supposed to be happening in the listen event at all.

Insofar as I can make any sort of sense of the code, I think you want to start reading your notecard at the very end of state_entry, and then build your categories list, once and for all,  in the dataserver event.   Then, in the listen event, you can compare what you hear with the categories list and do whatever it is you're trying to do.

NB -- You've quite correctly shortened the animation names to fit them on buttons.   However, this means that you can't rely on a response from the dialog menu being the name of an animation in the prim's inventory -- it could well be just the first 24 letters of the animation's name.   So you will need to find a way of referencing an animation from the responses you get via llDialog.

Link to comment
Share on other sites


PeterCanessa Oh wrote:

If you would care to explain your requirements more fully, more clearly and in English we may be able to help you more effectively.  You may well find that explaining exactly what the problem is - such as, for instance, telling us what isn't working at the moment - helps to clarify things in your own mind as well, helping you to solve your own problems.
[....]


Peter's right.  English would help. It's hard enough to follow someone else's lengthy script anyway, but it's impossible if we can't even understand what we're supposed to be looking for.

Link to comment
Share on other sites

wow didnt think it was that bad last night. .....it was here ill explane it again.

The script should work like this.

Touch object for menu>>>It reads notecard for categorys>>>makes main menu out of categorys>>>you select what category you want>>>goes to page containing that category...

Each Animation has a diff symbol infron of the name such as   (!@#$%^&*()) to mark its catigory.

the note card has caregoys listed one per line like this 

!=dane

@=house

#=more

and so one.

The point is be able to change both the names of the animations to what i want and the categorys in the notecard as i please. Like i said i was messing with that script for a LONG time so i know there is a lot of crap that does nothing i still need to take out. Ive tryed a bunch of things. menus are not my strong point ill post what the origenal menu script i wrote is not the crazy one lol. sorry for confision.

 

//============================integer mAPI_items_number;integer mAPI_last_page_items;integer mAPI_page = -1;                                      integer mAPI_pages_number;integer i;list mAPI_SetButtons(list menu_items){  if(mAPI_page == -1)    mAPI_GetPagesNumber(menu_items, llGetListLength(menu_items));  if(mAPI_items_number < 12)    return mAPI_SetButtonsSinglePage(llListSort(menu_items, 1, TRUE));  else    return mAPI_SetButtonsMultPages(llListSort(menu_items, 1, TRUE));}//----------------------------mAPI_GetPagesNumber(list src, integer src_len){    mAPI_items_number = src_len;      if(src_len > 11)      {      mAPI_pages_number = src_len / 9;      mAPI_last_page_items = src_len % 9;      if(mAPI_last_page_items != 0) mAPI_pages_number++;      else mAPI_last_page_items = 9;      }    else      {      mAPI_pages_number = 1;      mAPI_last_page_items = src_len;      }    mAPI_page = 1;          }list mAPI_SetButtonsMultPages(list src){    list wlist;    list page_src;    list dest;    list auto = ["<==, "Exit", "==&gt];    list matrix = [ 0,1,2,0,1,2,0,1,2];    integer first;    integer last;    integer i;    integer items = 9;      if(mAPI_page > mAPI_pages_number) mAPI_page = 1;    else if(mAPI_page == 0) mAPI_page = mAPI_pages_number;                                                             first = (mAPI_page - 1) * 9;                         // 0, 9, 18, etc    last = mAPI_page * 9 - 1;                            // 8, 16, 24, etc    page_src=llList2List(src, first, last);            if(mAPI_page == mAPI_pages_number)      {      items = mAPI_last_page_items;           if(mAPI_last_page_items % 3 == 1)                  //  7, 4 ,1        matrix = llDeleteSubList(matrix,1,2);      else if(mAPI_last_page_items % 3 == 2)             //  8, 5, 2        matrix = llDeleteSubList(matrix,2,2);      }    for(i=0; i< items; i++)      {      wlist = llList2List(page_src, i, i);      dest = llListInsertList(dest, wlist, llList2Integer(matrix, i));      }    dest = llListInsertList(dest, auto, 0);            return dest;}list mAPI_SetButtonsSinglePage(list src){    list wlist;    list dest;    list auto = ["Exit"];    list matrix = [ 0,1,2,0,1,2,0,1,2,0,1];    integer i;         if(mAPI_last_page_items % 3 == 1)                   // 10, 7, 4 ,1      matrix = llDeleteSubList(matrix,2,2);    else if(mAPI_last_page_items % 3 == 0)              //  9, 6, 3      matrix = llDeleteSubList(matrix,1,2);        for(i=0; i< mAPI_last_page_items; i++)      {      wlist = llList2List(src, i, i);      dest = llListInsertList(dest, wlist, llList2Integer(matrix, i));      }    dest = llListInsertList(dest, auto, 2);              return dest;}float   MENU_TIMEOUT = 30.0;list    inventory_items;integer lhandle;//------------------------------// user function, not a part of the mAPIMakeMenu(key id){  list menu;  string mtext = "Prim Content:\nPage ";  integer mchan;  menu = mAPI_SetButtons(inventory_items);                   // call mAPI to make alphabetical menu list   while(!mchan) mchan = -llFloor(llFrand(2000000));          // make some random channel, less lag with negative channels  mtext += (string)mAPI_page + " of " + (string)mAPI_pages_number + "   " + (string)llGetInventoryNumber(INVENTORY_ANIMATION) + "   " + "Animations found";  llSetTimerEvent(MENU_TIMEOUT);  lhandle = llListen(mchan, "", id, "");                     // listen on sending channel  llDialog(id, mtext, menu, mchan);                          // send menu}list Panim;//------------------------------default{    state_entry()    {                  string iname;       integer n = llGetInventoryNumber(INVENTORY_ANIMATION);      integer i;      for(i=0; i<n; i++)        {        iname = llGetInventoryName(INVENTORY_ANIMATION, i);        if(iname != llGetScriptName())          inventory_items += [llGetSubString(iname,0,23)];    //a menu button cannot have text longer than 24 chars        }      if(n > 0) llSay(0, "Content list completed. Touch for menu");      else llSay(0, "There is no content");    }    on_rez(integer param)    {      llResetScript();    }    attach(key attached)    {        llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);        llSetText("",<0.0,0.0,0.0>,1.0);}    changed(integer change)    {         if(change & CHANGED_INVENTORY)        {        llSay(0, "Inventory change detected. Loading New Animations");        llResetScript();        }    }    listen(integer ch, string name, key id, string mes)    {       list anims = llGetAnimationList( llGetOwner() );;      string wstr;      string iname;      iname = llGetInventoryName(INVENTORY_ANIMATION, i);      llSetTimerEvent(0.0);      llListenRemove(lhandle);      if(mes == "<==")                                       // previous page        {        --mAPI_page;        MakeMenu(id);        }      else if(mes == "==>")                                  // next page        {        ++mAPI_page;        MakeMenu(id);        }      else if(mes == "Exit")        {            list anims = llGetAnimationList( llGetOwner() );            integer n;            for ( n=0; n<llGetListLength( anims ) ;n++ )                    llStopAnimation( llList2String( anims,n ));                llSetText("",<0.0,0.0,0.0>,1.0);                llSleep(0.2);            }        else        {                        llStartAnimation(mes);            llSetText("Dancy,Dance",<1.0,0.0,0.0>,1.9);            llSleep(1.0);            llSetText("",<0.0,0.0,0.0>,1.0);        }    }            timer()                                                   // menu timeout    {      llSetTimerEvent(0.0);      llListenRemove(lhandle);    }    touch_start(integer total_num)    {        llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);      if(llDetectedKey(0) == llGetOwner())        MakeMenu(llGetOwner());     }}

 

Link to comment
Share on other sites

Making a script that plays animations from a menu is more or less trivial but still more complex than just making a menu of animations in the object content (and that is all the mAPI does). You got to deal with requesting permissions and therefore permissions event and you got to figure out what would stop animating, it's not a good idea to do it on a menu "Exit" button.

What I don't understand is why you wouldn't just order the script from someone instead of "messing with that script for a LONG time". A script of this complexity should be under or around 10 USD. Isn't it worth one-day lunch money to save yourself "LONG time" and a lot of frustration?

Link to comment
Share on other sites

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