Too hot to sleep, so added the distance check in aswell;
sync on : sync rate 0 : autocam off
randomize timer()
split=4
trees_min=10
trees_max=20
trees_dist=20
null2=make vector2(1)
make object plain 1,1000,1000
color object 1,rgb(255,0,0)
rotate object 1,270,0,0
position camera 0,600,-700
pitch camera down 50
areax=object size x(1)/split
areaz=object size y(1)/split
treeobj=1
treestart=treeobj+1
for x=1 to split
for z=1 to split
x1=(x-1)*areax
x2=x1+areax
z1=(z-1)*areaz
z2=z1+areaz
trees=rnd(trees_max-trees_min)+trees_min
for t=1 to trees
inc treeobj
make object cube treeobj,10
color object treeobj,rgb(0,255,0)
for tries=1 to 100
x#=rnd(x2-x1)+x1-(object size x(1)/2)
y#=5
z#=rnd(z2-z1)+z1-(object size y(1)/2)
oktoplace=1
if treeobj > treestart
for c=treestart to treeobj-1
d#=range2D(x#,z#,object position x(c),object position z(c))
if d# < trees_dist
oktoplace=0
exit
endif
next c
endif
if oktoplace=1 then exit
next tries
position object treeobj,x#,y#,z#
next t
next z
next x
do
sync
loop
function range2D(ax#,az#,bx#,bz#)
set vector2 1,ax#-bx#,az#-bz#
result#=length vector2(1)
endfunction result#
Boo!