Jump to content
  • 0
Sign in to follow this  
Triedge

Dynamic menu

Question

6 answers to this question

Recommended Posts

  • 0

That works well for small menus.
But I need that for example, note 10 conditions. and fulfilled every condition, adds an option to the menu.

Example:
select("Nothing"

+((BaseLevel >=5) ? ":Only Have 5 Level"

+((BaseLevel >=5) && counitem(501) > 0 ? ":Only Have 5 Level and have item 501":

+((BaseLevel >=5) && counitem(502) > 0 ? ":Only Have 5 Level and have item 502":"") )

 

Let's say you have level 5 and item 502.
Obviously the options 1,2 and 4 appear, but the 3 does not appear.

 

And while I understand as "creating" the menu, as it should make it work properly?

Share this post


Link to post
Share on other sites
  • 0

Blank options (which is for example the 2nd option in "opt1::opt3") are unselectable, so you can safely switch(select("opt1::opt3")) being sure nobody will ever use option 2.

 

Be careful the script command name is countitem, not counitem and you have unbalanced brackets there.

 

If you'd want that menu just work with level 5, you'd need to make your checks using the "is equal to" (==) operator, not the "greater or equal" (>=) one. Else you're correct on that.

 


 

About your example without minding these mistakes: its also hard to read to the point I've given up trying to fully understand that (no offense).

 

A better example (readable but not the most efficient of all possibilities) could be like this:

select("I meet no requisites:"	+ ((BaseLevel >= 5) ? "I'm level 5 or greater!" : "") + ":" // 2nd option	+ ((BaseLevel >= 5 && countitem(501)) ? "I'm level 5 or greater and I have "+getitemname(501)+"!" : "") + ":" // 3rd option	+ ((BaseLevel >= 5 && countitem(502)) ? "I'm level 5 or greater and I have "+getitemname(502)+"!" : "") // 4th and last option	)

 

If you badly want to make it the most efficient way you'd end up writing more and making it less readable than it currently is.

Share this post


Link to post
Share on other sites
  • 0

Mm ... what would be the correct way to run something like this:

	select("I meet no requisites:"	+ ((countitem(501)) ? "Option 1!" : "") + ":"	+ ((countitem(502)) ? "Option 2!" : "") + ":"	+ ((countitem(503)) ? "Option 3!" : "") + ":"	+ ((countitem(504)) ? "Option 4!" : "") + ":"	+ ((countitem(505)) ? "Option 5!" : "") + ":"	+ ((countitem(506)) ? "Option 6!" : "") + ":"	+ ((countitem(507)) ? "Option 7!" : "") + ":"	+ ((countitem(508)) ? "Option 8!" : "") + ":"	+ ((countitem(509)) ? "Option 9!" : "") + ":"	+ ((countitem(510)) ? "Option 10!" : "") + ":"	+ ((countitem(511)) ? "Option 11!" : "") + ":"	+ ((countitem(512)) ? "Option 12!" : "") + ":"	+ ((countitem(513)) ? "Option 13!" : "") + ":"	+ ((countitem(514)) ? "Option 14!" : "") + ":"	+ ((countitem(515)) ? "Option 15!" : "") + ":"	+ ((countitem(516)) ? "Option 16!" : "") + ":"	+ ((countitem(517)) ? "Option 17!" : "") + ":"	+ ((countitem(518)) ? "Option 18!" : "") + ":"	+ ((countitem(519)) ? "Option 19!" : "")	)

Share this post


Link to post
Share on other sites
  • 0

Seems correct.

 

Please keep in mind that empty options will appear as an empty option in your menu, so that "opt1::opt3" when rendered as a menu will be:

 

opt1opt3

And well, that's pretty much it if you don't have more questions.

Share this post


Link to post
Share on other sites
  • 0
prontera,150,180,5	script	jfhskdfjs	100,{	if ( BaseLevel < 5 ) {		mes "only level 5 or above";		close;	}	mes "asdasd";	next;	for ( .@i = 0; .@i < 19; .@i++ ) {		if ( countitem( 501 + .@i ) ) {			.@menu$ = .@menu$ + "Option "+( .@i +1 )+"!:";			.@option[.@c] = .@i;			.@itemid[.@c] = 501 + .@i;			.@c++;		}	}	.@s = select( .@menu$ ) -1;	mes "selected option no: "+( .@option[.@s] +1 );	mes getitemname( .@itemid[.@s] );	close;}

Share this post


Link to post
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.   Restore formatting

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.