Beret Posted June 7, 2013 Posted June 7, 2013 (edited) I have an npc as follows. switch(select(("name1:name2:cancel")) { case 1: mes "....."; close; case 2: switch(select(("name1:name2:back")) { case 1: mes "....."; close; case 2: mes "....."; close; case 3: // How to return to the main menu case 3: mes "....."; close; Edited June 7, 2013 by Beret Quote
DeadlySilence Posted June 7, 2013 Posted June 7, 2013 As far as I know you either have to put your main menu into a function or into a label. A function would be better as labels are not very good... Quote
Euphy Posted June 8, 2013 Posted June 8, 2013 You need to loop the main menu and break out of submenus. For examples, see the trunk/npc/re/guides/ directory. Quote
Beret Posted June 8, 2013 Author Posted June 8, 2013 (edited) You need to loop the main menu and break out of submenus. For examples, see the trunk/npc/re/guides/ directory. Then would be as follows? while (1) { switch(select(("name1:name2:cancel")) { case 1: mes "....."; close; case 2: set .@loop,1; while (.@loop) { switch(select(("name1:name2:back")) { case 1: mes "....."; close; case 2: mes "....."; close; case 3: set .@loop,0; break; case 3: mes "....."; close; Edited June 8, 2013 by Beret Quote
Capuche Posted June 8, 2013 Posted June 8, 2013 You have some curly errors but yeah something like that while (1) { switch( select( "name1:name2:cancel" ) ) { case 1: mes "....."; close; case 2: while ( .@loop == 0 ) { switch( select( "name1:name2:back" ) ) { case 1: mes "....."; close; case 2: mes "....."; close; case 3: set .@loop,1; break; } } break; case 3: mes "....."; close; } } 1 Quote
Beret Posted June 8, 2013 Author Posted June 8, 2013 (edited) You have some curly errors but yeah something like that while (1) { switch( select( "name1:name2:cancel" ) ) { case 1: mes "....."; close; case 2: while ( .@loop == 0 ) { switch( select( "name1:name2:back" ) ) { case 1: mes "....."; close; case 2: mes "....."; close; case 3: set .@loop,0; break; } } break; case 3: mes "....."; close; } } Now a bit more complicated as would be. switch( select( "name1:name2:cancel" ) ) { case 1: mes "....."; close; } case 2: set .@x, select( "name1:name2:back" ); switch(.@x){ case 1: break; case 2: break; case 3: // How to return to the main menu break; } next; mes "......."; close; case 3: mes "....."; close; Edited June 8, 2013 by Beret Quote
Emistry Posted June 8, 2013 Posted June 8, 2013 do{ mes "Main Menu ..."; next; switch( select( "Menu1","Menu2","Menu3" ) ){ Case 1: do{ switch( select( "Menu1-1","Menu1-2","Menu1-3" ) ){ Case 1: mes "Menu1-1"; break; Case 2: mes "Menu1-2"; break; Case 3: mes "Menu1-3"; break; default: break; } next; }while( select( "select menu1 again","return to main menu" ) == 1 ); break; Case 2: do{ switch( select( "Menu2-1","Menu2-2","Menu2-3" ) ){ Case 1: mes "Menu2-1"; break; Case 2: mes "Menu2-2"; break; Case 3: mes "Menu2-3"; break; default: break; } next; }while( select( "select menu2 again","return to main menu" ) == 1 ); break; Case 3: do{ switch( select( "Menu3-1","Menu3-2","Menu3-3" ) ){ Case 1: mes "Menu3-1"; break; Case 2: mes "Menu3-2"; break; Case 3: mes "Menu3-3"; break; default: break; } next; }while( select( "select menu3 again","return to main menu" ) == 1 ); default: break; } mes "Redirecting...."; }while( select( "Continue","Close" ) == 1 ); close; just add a "loop" at every menu ....and check the selection made by users to decide whether return to main menu or not... there are also other way like...using goto ... and etc... Quote
Beret Posted June 8, 2013 Author Posted June 8, 2013 do{ mes "Main Menu ..."; next; switch( select( "Menu1","Menu2","Menu3" ) ){ Case 1: do{ switch( select( "Menu1-1","Menu1-2","Menu1-3" ) ){ Case 1: mes "Menu1-1"; break; Case 2: mes "Menu1-2"; break; Case 3: mes "Menu1-3"; break; default: break; } next; }while( select( "select menu1 again","return to main menu" ) == 1 ); break; Case 2: do{ switch( select( "Menu2-1","Menu2-2","Menu2-3" ) ){ Case 1: mes "Menu2-1"; break; Case 2: mes "Menu2-2"; break; Case 3: mes "Menu2-3"; break; default: break; } next; }while( select( "select menu2 again","return to main menu" ) == 1 ); break; Case 3: do{ switch( select( "Menu3-1","Menu3-2","Menu3-3" ) ){ Case 1: mes "Menu3-1"; break; Case 2: mes "Menu3-2"; break; Case 3: mes "Menu3-3"; break; default: break; } next; }while( select( "select menu3 again","return to main menu" ) == 1 ); default: break; } mes "Redirecting...."; }while( select( "Continue","Close" ) == 1 ); close; just add a "loop" at every menu ....and check the selection made by users to decide whether return to main menu or not... there are also other way like...using goto ... and etc... more would I do as in the model that the Capuche made Emistry? the problem is only in set @ x, select ("name1 name2: back:"); switch (@ x) { Quote
Emistry Posted June 8, 2013 Posted June 8, 2013 while (.@loop) { switch(select(("name1:name2:back")) { case 1: mes "....."; break; case 2: mes "....."; break; case 3: set .@loop,0; } } break; Quote
Beret Posted June 8, 2013 Author Posted June 8, 2013 (edited) can close, got it. Edited June 8, 2013 by Beret Quote
Question
Beret
I have an npc as follows.
10 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.