Jump to content
  • 0

code optimization


shadowscreen

Question


  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  76
  • Reputation:   11
  • Joined:  04/13/12
  • Last Seen:  

Hey guys,

 

sorry that I have to bother you but somehow im completely silly right now.

 

Is it possible to pass an array as the result of a menu / selection?

 

 

example (current)

setarray .@neutralRes[1], 101,102,103;

set .@menu,select("Neutral:Fire:Water:Wind:Earth:Shadow:Holy:Ghost");
	
	switch (.@menu) {
		case 1:
			set .@bonus, callfunc("getBonusLevel", .@neutralRes);
		break;

example (should look like this)

setarray .@neutralRes[1], 101,102,103;

set .@menu,select("Neutral",.@neutralRes,"Fire",.@fireRes,...etc);
set .@bonus, callfunc("getBonusLevel", .@menu);

// or even better

set .@bonus, callfunc("getBonusLevel", select("Neutral",.@neutralRes,"Fire",.@fireRes,...etc));

Hope I could clarify my desire,

thanks in advance!!!!

Edited by shadowscreen
Link to comment
Share on other sites

5 answers to this question

Recommended Posts


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

mes "Select Element";
.@i = select( implode( .element_name$,":" ) ) - 1;
callfunc( "getBonusLevel",.element_value[.@i] );
close;

OnInit:
setarray .element_name$,"Fire","Water","Earth","Wind";
setarray .element_value,100,200,300,400;
end;

I have no idea what you actually want.

 

your first method, almost correct except the missing index to link to your array..

 

your second method, wrong at menu selection.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  76
  • Reputation:   11
  • Joined:  04/13/12
  • Last Seen:  

well its just an example,   the current one is already working in my script

setarray .@str[1],30000,30050,30100;  // item IDs of lvl 1/2/3/....  enchantmentStones
setarray .@dex[1],30001,30051,30101
// ^ the same with int / agi / vit / luk

_statpoints:
    mes "["+strnpcinfo(1)+"]";
    mes "And wich statpoint should I apply?";
    set .@menu,select("Str:Dex:Int:Vit:Agi:Luk");
    switch (.@menu) {
        case 1:
            set .@bonus, callfunc("GetBonusLevel", .@str, .@currentBonus, .@maxEnchantmentLevel, .@defaultEnchantmentLevel);
        break;
        case 1:
            set .@bonus, callfunc("GetBonusLevel", .@dex, .@currentBonus, .@maxEnchantmentLevel, .@defaultEnchantmentLevel);
        break;

currently, there is a switch with 6 cases for each attribute     ^ like this

 

And i want to remove the switch somehow. Because in my opinion its nasty code :<

 

The result should look some kind of this   (you can see my  following example as pseudocode) and i would like to know how i can realize that

setarray .@str[1],30000,30050,30100;  // item IDs of lvl 1/2/3/....  enchantmentStones
setarray .@dex[1],30001,30051,30101
// ^ the same with int / agi / vit / luk

_statpoints:
    mes "["+strnpcinfo(1)+"]";
    mes "And wich statpoint should I apply?";
    set .@selectedMenuOption,select(.@str,.@dex);   <-----  if i select str,  .@selectedMenuOption should be the array .@str
    
    set .@bonus, callfunc("GetBonusLevel", .@selectedMenuOption, .@currentBonus, .@maxEnchantmentLevel, .@defaultEnchantmentLevel);

 I hope its kinda understandable now ^^'

Edited by shadowscreen
Link to comment
Share on other sites


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

content in post#3 already illustrate how it can be written.

exactly the same thing that you want.

 

and same as i mentioned in post#3

your last exmple, still same, problem when writing the menu part ==''

select doesnt support 2 parameter

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  76
  • Reputation:   11
  • Joined:  04/13/12
  • Last Seen:  

oh, i see

 

thanks alot !!!

 

I couldnt see the solution in post #3 by myself x_x    

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...