Jump to content

F_Randomizer randomize and split array into arrays 1.0.0


2 Screenshots

About This File

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


×
×
  • Create New...