Jump to content

Utility: F_Randomizer randomize and split array into arrays


sader1992

Recommended Posts


  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1677
  • Reputation:   703
  • Joined:  12/21/14
  • Last Seen:  

F_Randomizer randomize and split array into arrays


this function can be used to randomize and split thr first array passed in to it to the other arrays

Warning! the main array size must be divided by the count of the other arrays

for example , you have .@main size 4, you should not send 3 arrays cuz 4/3 = 1 and 1 left , it will fail!

the example npc from the photo is included in the file

also here it is

-	script	Randomizer_test	-1,{
OnInit:
	debugmes "================================================";
	setarray .@main,1,2,3,4,5,6,7,8,9,10,11,12;
	for(.@i=0;.@i<getarraysize(.@main);.@i++){
		debugmes "" + .@main[.@i];
	}
	debugmes "================================================";
	debugmes "Split and randomize the elements of .@main into .@a .@b .@c .@d .@e .@f .@g arrays";
	debugmes "================================================";
	
	F_Randomizer(.@main,.@a,.@b,.@c,.@e,.@f,.@g);
	
	for(.@i=0;.@i<getarraysize(.@a);.@i++){
		debugmes ".@a " + .@a[.@i];
	}
	
	for(.@i=0;.@i<getarraysize(.@b);.@i++){
		debugmes ".@b " + .@b[.@i];
	}
	
	for(.@i=0;.@i<getarraysize(.@c);.@i++){
		debugmes ".@c " + .@c[.@i];
	}
	
	for(.@i=0;.@i<getarraysize(.@e);.@i++){
		debugmes ".@e " + .@e[.@i];
	}
	
	for(.@i=0;.@i<getarraysize(.@f);.@i++){
		debugmes ".@f " + .@f[.@i];
	}
	
	for(.@i=0;.@i<getarraysize(.@g);.@i++){
		debugmes ".@g " + .@g[.@i];
	}
	debugmes "==================================================================================";
end;
}

 

the best place to put the function in is at the end of rathena/npc/other/Global_Functions.txt file


  • Submitter
  • Submitted
    08/20/2020
  • Category
  • Video
  • Content Author
    sader1992

 

  • Like 1
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
Reply to this topic...

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