How to add other distance parameter in this voronoi distance command here?

So, what should I do if I wanted other distance algorithm for this code?

#@cli rep_cellular_noise: 0<amplitude<=1,iterations>0
rep_cellular_noise:
amplitude=$1
foreach { 
	100%,100%,100%
	rm.. 
	repeat $2 {
		__$0_apply_noise[0]
		+_$0_create_cell[0]
		n. 0,{1-$>/10}
	}
	rm[0] +
}
__rep_cellular_noise_apply_noise: # Subcommand
gt 0
+noise $amplitude,2 eq. 1
max
label_fg 0
_rep_cellular_noise_create_cell:
+voronoi
L={iM+1}
$L,1,1,3      # 1. Create a initial list of coordinates all set to 0. Number of coordinates is equal to number of values in voronoi
eval[-2] :" 
	begin(
		X=Y=Z=vector(#w#-1);
	);
	if(i&&i#0,
		X[i]=x;
		Y[i]=y;
		Z[i]=z;
	);
	end(
		merge(X,|);
		merge(Y,|);
		merge(Z,|);
		repeat(w#-1,p,
			I[#-1,p]=[X[p],Y[p],Z[p]];
		);
	);
	"
+f[-2] norm([x,y,z]-I[#-1,i]) # This is where distance goes. Only Euclidean.
k[-1]

Test:

$ 512,512 rep_cellular_noise .2,1

Turns out I didn’t need to do all of that, it was just as simple as using distance.

$ 512,512 noise .05,2 abs repeat 4 +distance[0] 100%,$> n. 0,255 done rm[0] a[-4,-3] x a[-2,-1] x a y

That being said, I would like new distance options here. Instead of getting the closest distance, I would like to get the second closest distance instead. Also, is there like a way to do voronoi, but more shaped like the first and second output?