Jump to content

Question

Posted

So my script is just like this..

//this is the item choices
setarray .beadID[1],4739,4709,4749,4729,4759,4719,4790,4794,4763,4799,4802,4825,4831,4841,4844,4849,4848,4852,4868;
set .@BeadMenu$,"";

//loop for menufor( set .@i,1; .@i < getarraysize( .beadID ); set .@i,.@i + 1 ){
set .@BeadMenu$,.@BeadMenu$ + getitemname( .beadID[.@i] )+":";
}

//makes a selection of what item you want
set .@Bead,select( .@BeadMenu$ );
 

 

 

 

 

I want the player to choose three kinds of bead or loop it 3 times and save it into an array.

set .beadChoices[1],.beadID[.@Bead]1,.beadID[.@Bead]2,.beadID[.@Bead]3;

 

How can i achieve this?

 

2 answers to this question

Recommended Posts

Posted

Hello,

 

I wrote this little code snippet and I hope that helps you.

 

The logic should be correct, but not checked for syntax errors.

 

	// array with options (item id) to build the menu
	setarray .beadID[0], 4001, 4002, 4003, 4004, 4005;
	// clear the array with possible previous select
	deletearray .@selections[0], getarraysize(.beadID);	
	
	// how many options can select before the script ends the loop
	set .@how_many_selects, 3;
	
	while (.@how_many_selects > 0)
	{
		// build dynamic menu showing the selected options
		set .@menu_str$, "";
		for ( set .@i, 0; .@i < getarraysize(.beadID); set .@i, .@i+1 )
			set .@menu_str$, ( .@menu_str$ == "" ? "" : .@menu_str$ + ":" ) + ( .@selections[.@i] ? ">" : "" ) + getitemname(.beadID[.@i]);
	
		// does the selection
		set .@select, select(.@menu_str$) - 1;

		if (.@selections[.@select]) {
			set .@selections[.@select], 0;
			set .@how_many_selects, .@how_many_selects + 1;
		}
		else {
			set .@selections[.@select], 1;
			set .@how_many_selects, .@how_many_selects - 1;
		}
	
		// prevent infinite loop errors
		sleep2 1;
	}
	
	// at this point, .@selections should contains indexes with the selected options, keeping the associative indexes with .beadID
	// so, if .@selections[10] == 1 means that .beadID[10] was selected
	
	for ( set .@i, 0; .@i < getarraysize(.beadID); set .@i, .@i+1 ) {
		if (.@selections[.@i]) {
			getitem .beadID[.@i], 1;
		}
	}
	
Posted

Thank you for this sir! I edited your work into much simpler one, it will let you select up to 3x with the same item.

 

   

 

 setarray .beadID[1],4739,4709,4749,4729,4759,4719,4790,4794,4763,4799,4802,4825,4831,4841,4844,4849,4848,4852,4868;
    
    deletearray .@selections[1], getarraysize(.beadID);
    
    set .@how_many_selects, 4;
    
    while (.@how_many_selects > 1)
    {
    set .@BeadMenu$,"";
    
    for( set .@i,1; .@i < getarraysize( .beadID ); set .@i,.@i + 1 ){
        set .@BeadMenu$,.@BeadMenu$ + getitemname( .beadID[.@i] )+":";
    }
    set .@Bead,select( .@BeadMenu$ );
    set .@how_many_selects, .@how_many_selects - 1;
    set .@selections[.@how_many_selects], .beadID[.@Bead];
    sleep2 1;
    }
    
    for ( set .@i, 1; .@i < getarraysize(.beadID); set .@i, .@i+1 ) {
        if (.@selections[.@i]) {
            //getitem .@selections[.@i],1;
            dispbottom "ITEM ID"+.@selections[.@i];
        }
    }
    close;
 

Thanks for the snippet.

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...