Try this code to get an idea how to use a function
Also cloning is faster than loading every object when they are the same object. Load the first one, then clone other copies.
global nextobject=20000
set text opaque
autocam off
`Just making a box object and texture to use
`--------------------------
if file exist ("entitybank\objects\box.dbo")=0
make object box 1,10,10,10
save object "entitybank\objects\box.dbo",1
delete object 1
endif
if file exist ("texture1")=0
cls
print "test"
get image 1,0,0,40,10
save image "texture1",1
delete image 1
endif
`--------------------------
load image "texture1",19
position camera 250,250,-400
point camera 250,250,0
`main loop
do
if keystate(3)=1 then _next_object(1)
`some debug code
set cursor 0,0
print "Next Object Number"
print nextobject
loop
`Set up a nice function to add the number of objects you want each time
function _next_object(numobjects)
`You don't need this anymore, using one load variable for all your objects won't work right
`if keystate(3)=0 then load=0
for i=nextobject to nextobject+numobjects
if object exist(i)=0
load object "entitybank\objects\box.dbo",i
` position object i, object position x( 2 ) , 5, object position z( 2 )
position object i,rnd(500),rnd(500),0
texture object i,19
inc i
endif
next i
inc nextobject,numobjects
endfunction