I wrote this in response to a question so I thought It would be a good idea to post it here as well.
You can use the function copy_object() to make a duplicate of a loaded or created object. The only thing you have to consider is the texture. If you load or create the texture separately, then it can be applied to the newly created objects.
Fucntion:
copy_object(inobj,outobj,texture)
inobj = the original object number to be copied
outobj = the new object number that will be created
texture = the image number to use as the texture
rem copy object
rem latch october 2006
set display mode 800,600,32
sync on
sync rate 60
autocam off
randomize timer()
rem create a texture
box 0,0,55,100
ink rgb(255,0,0),0
box 40,120,128,128
ink rgb(255,255,255),0
get image 1,0,0,128,128
rem create an object
make object cube 1,10
texture object 1,1
`hide object 1
rem copy object
for copy = 2 to 20
copy_object(1,copy,1)
position object copy,80+(5*copy),(10*copy)-100,0
sync
next copy
rem position camera
position camera 140,0,-150
rem rotate cube copies
do
ang#=wrapvalue(ang#+1)
for cubes = 1 to 20
yrotate object cubes,ang#
next cubes
sync
loop
end
function copy_object(inobj,outobj,texture)
rem get available memblock and mesh
mesh1=get_mesh(1)
mesh2=get_mesh(mesh1+1)
mem=get_memblock(1)
make mesh from object mesh1,inobj
make memblock from mesh mem,mesh1
make mesh from memblock mesh2,mem
make object outobj,mesh2,texture
rem don't need memblock or mesh
delete mesh mesh1
delete mesh mesh2
delete memblock mem
endfunction
function get_mesh(num)
while mesh exist(num)=1
inc num
endwhile
endfunction num
function get_memblock(num)
while memblock exist(num)=1
inc num
endwhile
endfunction num
Enjoy your day.