Jump to content
  • 0
Sign in to follow this  
Kavaline

Any suggestion for matrix?

Question

Hi, I need write this kind of script:

setarray .arrayAn[1], 1, 2, 3, 4, 5;
setarray .arrayA$[1], "a", "b", "c", "d", "e";
setarray .arrayBn[1], 6, 7, 8, 9, 10, 11;
setarray .arrayB$[1], "f", "g", "h", "i", "j", "k";
setarray .arrayCn[1], 12, 13, 14, 15;
setarray .arrayC$[1], "l", "m", "n", "o";

.@value = rand(1,getarraysize(.arrayAn));
.resultn[1] = arrayAn[.@value];
.result$[1] = arrayA$[.@value];
   
.@value = rand(1,getarraysize(.arrayBn));
.resultn[2] = arrayBn[.@value];
.result$[2] = arrayB$[.@value];
     
.@value = rand(1,getarraysize(.arrayCn));
.resultn[3] = arrayCn[.@value];
.result$[3] = arrayC$[.@value];

 

Have any way to use matrix or other solution, doing something like this:

 

setarray .arrayn[1][1], 1, 2, 3, 4, 5;
setarray .array$[1][1], "a", "b", "c", "d", "e";
setarray .arrayn[2][1], 6, 7, 8, 9, 10, 11;
setarray .array$[2][1], "f", "g", "h", "i", "j", "k";
setarray .arrayn[3][1], 12, 13, 14, 15;
setarray .array$[3][1], "l", "m", "n", "o";

for (.@i = 1; .@i <= 3; ++.@i) {
	.@value = rand(1,getarraysize(.arrayn[.@i]));
	.resultn[.@i] = arrayn[.@i][.@value];
	.result$[.@i] = array$[.@i][.@value];
}

This is a script with testing values that I'm using to find a solution, my original script will needs 100 loops in this case (and will only use integers, for IDs and numbers, in non logical or consecutive order), and without matrix is really unfair. Have another option that help me?

Edited by Kavaline
Giving more information

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 1

I did it in the following way, I hope it helps.

prontera,161,181,5	script	Test Code	112,{

	//delete arrays permanent in npc
	deletearray .resultn[0],getarraysize(.resultn);
	deletearray .result$[0],getarraysize(.result$);

	for(set .@i,1; .@i<=3; set .@i,.@i+1)
	{		
		switch(.@i)
		{	
			//arrays temporary
			case 1:	setarray .@arrayn[1],1,2,3,4,5;			setarray .@array$[1],"a","b","c","d","e";		break;
			case 2:	setarray .@arrayn[1],6,7,8,9,10,11;		setarray .@array$[1],"f","g","h","i","j","k";	break;
			case 3:	setarray .@arrayn[1],12,13,14,15;		setarray .@array$[1],"l","m","n","o";			break;
		}
		
		//Save values
		setarray .resultn[.@i],.@arrayn[rand(1,getarraysize(.@arrayn)-1)];
		setarray .result$[.@i],.@array$[rand(1,getarraysize(.@array$)-1)];
		
		//show values
		dispbottom ".resultn value["+.@i+"]: "+.resultn[.@i];
		dispbottom ".result$ value["+.@i+"]: "+.result$[.@i]+"";
		
		//delete array temporary
		deletearray .@arrayn[0],getarraysize(.@arrayn);
		deletearray .@array$[0],getarraysize(.@array$);
	}
	end;
}

 

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.