Tabris Daxter Posted August 29, 2011 Share Posted August 29, 2011 hey again.the problem i'm now having is somewhat related to Strided List Trouble.here is the updated code.list NCnames; list type; list catagory; list scenename; list btnlvl1 = ["scene","on","off"]; list output = []; key toucherID; integer diagchan; integer Ldiag; scene_lst() { NCnames = []; integer numNC = llGetInventoryNumber(INVENTORY_NOTECARD); integer x = 0; while (x < numNC) { NCnames += llParseString2List(llGetInventoryName(INVENTORY_NOTECARD,x++),["."],[]); } integer NClstlen = llGetListLength(NCnames); integer i = 0; while (i < NClstlen) { type += llList2String(NCnames,i++); catagory += llList2String(NCnames,i++); scenename += llList2String(NCnames,i++); } } list ListUnique( list lAll ) { integer i; list lFiltered = llList2List(lAll, 0, 0); integer iAll = llGetListLength( lAll ); for (i = 1; i < iAll; ++i) { if ( llListFindList(lFiltered, llList2List(lAll, i, i) ) == -1 ) { lFiltered += llList2List(lAll, i, i); } } return lFiltered; } default { state_entry() { diagchan = -1000; Ldiag = llListen(diagchan,"","",""); scene_lst(); } touch_start(integer badtouch) { toucherID = llDetectedKey(0); llDialog(toucherID,"HI ALL",btnlvl1,diagchan); llSetTimerEvent(30); } listen(integer chan, string name, key id, string msg) { if (chan == diagchan) { integer menulvl1 = llListFindList(btnlvl1,[msg]); integer menulvl2 = llListFindList(catagory,[msg]); integer menulvl3 = llListFindList(scenename,[msg]); if (menulvl1 != -1) { if (llList2String(btnlvl1, menulvl1) == msg) { output += [msg]; llDialog(toucherID,llList2String(btnlvl1, menulvl1),ListUnique(catagory),diagchan); llSetTimerEvent(30); llSay(0,(string)llGetListLength(output)); } } else if (menulvl2 != -1) { if (llList2String(catagory, menulvl2) == msg) { output += [msg]; llDialog(toucherID,llList2String(catagory, menulvl2),ListUnique(scenename),diagchan); llSetTimerEvent(30); llSay(0,(string)llGetListLength(output)); } } else if (menulvl3 != -1) { if (llList2String(scenename, menulvl3) == msg) { output += [msg]; llSay(0,(string)llGetListLength(output)); llSay(0,llDumpList2String(output,".")); llSetTimerEvent(5); } } } } timer() { llListenRemove(Ldiag); llSetTimerEvent(0); } } notecard NAMES are in the format of scene.beach.palm tree & scene.city.hotel etc etcone of my current problems is one i've been having with another semi-related project too.it will run through the dialog sequence (lvl1 > lvl2 > lvl3 >> output) but will not run through again without resetting the script. the second problem is that the lvl3 menu is just the scenename list (i know it's coded this way ATM)i need some way of filtering it based on the output of the lvl2 menu Link to comment Share on other sites More sharing options...
Void Singer Posted August 29, 2011 Share Posted August 29, 2011 well the reason it needs reset is because you remove the listen, but never restart it (it's only in state entry) as for the other problem, it depends on how much control of the encoding you have. the way I've handled submenus like this in the past is to encode a number with each menu, that is the starting index of the next levels options. when getting that command I read the index for the for the current command, and the one after it, and use those indexes to find the range option to pull from the next levels list... it ends up looking something like.... vLst1a = ["a", "b"]; vLst1b = [0, 2]; vLst2a = ["a-1", "a-2", "b-1", "b-2]; vLst2b = [0, 2, 4, 6]; vLst3x = ["a-1-a", "a-1-b", "a-2-a", "a-2-b", "b-1-a", "b-1-b", b-2-a", "b-2-b"] if the command is "a", I grab the sam index from the next lists count, "0", and the one after it "2" and subtract 1 from the second number to get a range of "0,1" to pull from the second level menu options to put into the dialog (resulting in ["a-1", "a-2"] being used) if the command were "b" I would grab "2", and attempting to grab the next index would result in "0", which after we subtract one from just as above, is negative one, giving us a range of "2,-1" which results in ["b-1", "b-2"] the last level menu never needs a matched list, but I sometime use one to carry out individual actions. how you build those lists is up to you, and you can actually encode the index numbers with the menu by using spaces or other tricks, but the same principle applies. Link to comment Share on other sites More sharing options...
Tabris Daxter Posted September 7, 2011 Author Share Posted September 7, 2011 Void sorry for the late reply. would you be able to give a code snippet so i can work through it. TY Link to comment Share on other sites More sharing options...
Void Singer Posted September 7, 2011 Share Posted September 7, 2011 list vLst1a = ["a", "b"];list vLst1b = [0, 2];list vLst2a = ["a-1", "a-2", "b-1", "b-2"];list vLst2b = [0, 2, 4, 6];list vLst3x = ["a-1-a", "a-1-b", "a-2-a", "a-2-b", "b-1-a", "b-1-b", "b-2-a", "b-2-b"];integer gIntChn = -42;default{ touch_end( integer vIntTch ){ llDialog( llDetectedKey( 0 ), "First Level Menu", vLst1a, gIntChn ); } listen( integer vIntChn, string vStrNom, key vKeySrc, string vStrMsg ){ if (~vIntChn = llListFindList( vLst1a, [vStrMsg] )){ llDialog( vKeySrc, "Second Level Menu", llList2List( vLst2a, llList2Integer( vLst1b, vIntChn ), ~-llList2Integer( vLst1b, ++vIntChn ), gIntChn ); }else if (~vIntChn = llListFindList( vLst2a, [vStrMsg] )){ llDialog( vKeySrc, "Third Level Menu", llList2List( vLst3a, llList2Integer( vLst2b, vIntChn ), ~-llList2Integer( vLst2b, ++vIntChn ), gIntChn ); }else if (~vIntChn = llListFindList( vLst3x, [vStrMsg] )){ llRegionSayTo( vKeySrc, 0, "You Picked " + vStrMsg ); } }} if (~variable = function-that-return-an-index) //-- quick way to save an index and test that it's not -1 (which means not found)at the same time ~-number //-- quick hack that means subtract 1 from this number ETA: the way I used to build these is to list the menu, then it's options in a notecard with keywords... if it was a menu, add it to the list of menus (1a), and get the current length of submenus list (2a) and add that as an element to to the index finder (1b). if it was an option, add it to the options list. for more depth you can use different keywords to denote the menu level, or just search to see if the name appears in other levels..... somewhere I have a whole menuing system I built on this premise, with both unlimited depth AND unlimited options, but can't seem to find it.... it's a bit more complex than what's shown here though. Link to comment Share on other sites More sharing options...
Tabris Daxter Posted September 8, 2011 Author Share Posted September 8, 2011 Hi Void, i've sent you a copy of the latest version in-world. it also includes the notecards that form the menu. TY Link to comment Share on other sites More sharing options...
Void Singer Posted September 8, 2011 Share Posted September 8, 2011 fixed a couple of missing quote marks above. in general I reserve my inworld time for myself, and clients; and at the moment I can't even get inworld. Link to comment Share on other sites More sharing options...
Tabris Daxter Posted September 8, 2011 Author Share Posted September 8, 2011 Just wanted you to have a copy. I'm having a problem with The lvl3 menu only getting 50% of The entries. The "Beach" category works fine. The "City" category has 2 options (not The right ones) The "WTF" & "Space" categories are empty. Any help appreciated Link to comment Share on other sites More sharing options...
Void Singer Posted September 8, 2011 Share Posted September 8, 2011 if you are worried about posting the source publicly in the thread, you are welcome to pass me a PM on the forums here with it. this is as close as I can get to inworld at the moment anyway =/ Link to comment Share on other sites More sharing options...
Tabris Daxter Posted September 9, 2011 Author Share Posted September 9, 2011 not worried about the code being in public. most of it came from either the forums or the wiki. i just wanted to give you a copy that uses MY source data when building the lists incase that was the problem. Link to comment Share on other sites More sharing options...
Recommended Posts
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