Jump to content
  • 0

Switch/Menu Using an array


crazyarashi

Question


  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

Hi Good Day Rathena, Im Still in the midst of studying C++ and want to ask a question about making a menu/switch select using an array.
Maybe an example will do im a bit confused reading old posts about it :))
 

  • Upvote 1
Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

you can try like ..

setarray .@menu_item$, 
	"Menu 1",
	"Menu 2",
	"Menu 3";
.@menu_item_size = getarraysize(.@menu_item$);
for (.@i = 0; .@i < .@menu_item_size; .@i++) {
	.@menu$ = .@menu$ + (.@i > 0 ? ":" : "") + .@menu_item$[.@i];
}
.@i = select( .@menu$ ) - 1;
mes "You selected menu : "+ .@menu_item$[.@i];

or

setarray .@menu_item$, 
	"Menu 1",
	"Menu 2",
	"Menu 3";
.@menu$ = implode(.@menu_item$, ":");
.@i = select( .@menu$ ) - 1;
mes "You selected menu : "+ .@menu_item$[.@i];

 

  • Upvote 2
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  8
  • Reputation:   5
  • Joined:  02/17/12
  • Last Seen:  

little example

setarray A_menu[0],"menu 02","menu 03","menu 04";
set .@menu,"menu 01";//Build First Item on Menu, cant put in <for>, it will looping
for(set .@i,0; .@i < getarraysize(A_menu[0]);.@i++) {// add array item to menu
  set .@menu,.@menu+":"+A_menu[.@i];
}
select(.@menu);//menu list show out

 

  • Upvote 2
Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

13 minutes ago, Emistry said:

you can try like ..


setarray .@menu_item$, 
	"Menu 1",
	"Menu 2",
	"Menu 3";
.@menu_item_size = getarraysize(.@menu_item$);
for (.@i = 0; .@i < .@menu_item_size; .@i++) {
	.@menu$ = .@menu$ + (.@i > 0 ? ":" : "") + .@menu_item$[.@i];
}
.@i = select( .@menu$ ) - 1;
mes "You selected menu : "+ .@menu_item$[.@i];

or


setarray .@menu_item$, 
	"Menu 1",
	"Menu 2",
	"Menu 3";
.@menu$ = implode(.@menu_item$, ":");
.@i = select( .@menu$ ) - 1;
mes "You selected menu : "+ .@menu_item$[.@i];

 

May I ask what is the use of implode. I haven't studied that yet nor i haven't seen it yet :o

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  664
  • Reputation:   672
  • Joined:  11/12/12
  • Last Seen:  

You can check out the script commands over here: https://github.com/rathena/rathena/blob/master/doc/script_commands.txt

Search for *implode.

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

5 minutes ago, Tokei said:

You can check out the script commands over here: https://github.com/rathena/rathena/blob/master/doc/script_commands.txt

Search for *implode.

Wokie didn't know it's in there :o

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...