I'll just post the whole code so you can see what's going on. It's not much. I'm not writing a string, I'm creating a variable and defining it within a for/next command based on the condition that TestLevel1Data=9.
rem Setup display
set display mode 800,600,32
set window on
autocam off
hide mouse
rem Create backdrop item
make object box 1000,(23*50),(12*50),1
position object 1000,object size x(1000)/2+25,object size y(1000)/2+25,25
color object 1000,rgb(128,128,0)
make object collision box 1000,-575,-300,-.5,575,300,.5,0
rem make Crane object
make object box 1001,25,25,10
position object 1001,object size x(1000)/2+25,object size y(1000)/2+25,-200
make object collision box 1001,-12.5,-12.5,-5,12.5,12.5,5,0
color object 1001,rgb(60,60,120)
rem light
color light 0,128,128,196
set ambient light 30
color ambient light rgb(30,30,90)
set directional light 0,0,0,1
position light 0,575,300,-1000
SET SHADOW SHADING ON 1001,-1,1000,1
maxO=20
dim OBdata(maxO)
dim OBnum(maxO)
for P = 0 to maxO
OBdata(P)=0
OBnum(P)=0
next P
rem Create a level
`also randomize colors and sizes
NewObject=1
LevelObject=2000
for y=12 to 1 step -1
for x=1 to 23
read TestLevel1Data
if TestLevel1Data=1
make object box LevelObject,50,50,50
position object LevelObject,x*50,y*50,0
make object collision box LevelObject,-25,-25,-25,25,25,25,0
color object LevelObject,rgb(40,180,120)
inc LevelObject
endif
if TestLevel1Data=9 and NewObject<maxO+1
make object sphere NewObject,25
make object collision box NewObject,-12.5,-12.5,-12.5,12.5,12.5,12.5,0
color object NewObject,rgb(200,0,200)
position object NewObject,x*50,y*50,0
SET SHADOW SHADING ON NewObject,-1,1000,1
x+str$(NewObject)#=x*50
y+str$(NewObject)#=y*50
z+str$(NewObject)#=0
OBdata(NewObject)=1
OBnum(NewObject)=NewObject
inc NewObject
endif
next x
next y
rem Variables
x#=575
y#=300
z#=-200
rem Manual synchronisation
sync on
sync rate 0
rem Main loop
do
set cursor 0,0
print "FPS: "+str$(screen fps())
print "block height: "+str$(z#)
print "toggle: "+str$(toggle)
rem Control character
if upkey()=1
y#=y#+1
endif
if downkey()=1
y#=y#-1
endif
if rightkey()=1
x#=x#+1
endif
if leftkey()=1
x#=x#-1
endif
if spacekey()=1 and object collision(1001,1)=0 and toggle=0
z#=z#+1
endif
if z#=0 or object collision(1001,1)>0 then toggle=1
if spacekey()=1 and z#>-200 and toggle=1
z#=z#-1
endif
if z#=-200 then toggle=0
for P = 0 to maxO
if OBData(P)=1
if object collision(1001,P)>0
x+str$(OBnum(P))#=x#
y+str$(OBnum(P))#=y#
z+str$(OBnum(P))#=z#+12
endif
if returnkey()=1 and object collision(1001,P)>0
z+str$(OBnum(P))#=z+str$(OBnum(P))#+1
endif
if object collision(1,0)=0
z+str$(OBnum(P))#=z+str$(OBnum(P))#
endif
position object P,x+str$(OBnum(P))#,x+str$(OBnum(P))#,z+str$(OBnum(P))#
endif
next P
position object 1001,x#,y#,z#
rem Control camera
camX#=(object size x(1000)/2+25)/2+x#/2
camY#=(object size y(1000)/2+25)/2+y#/2
camZ#=z#-200
position camera camX#,camY#,camZ#
point camera x#,y#,z#
rem Update screen
sync
rem End main loop111111
loop
TestLevel1Data:
data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
data 1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,1,1,1,1,1,1,1,0,0,0,0,1,1,0,0,9,1,1,0,0,1
data 1,0,0,0,9,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,1,0,1,0,0,9,0,0,0,0,0,0,0,0,0,1,1
data 1,1,1,0,0,0,1,0,1,0,0,0,1,1,0,1,0,0,0,0,0,0,1
data 1,0,0,1,0,0,1,9,1,0,1,0,0,1,0,1,1,1,1,1,1,1,1
data 1,0,0,0,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,1,1,0,0,0,0,1,1,0,0,1,1,1,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1
data 1,1,0,9,0,1,0,0,0,0,0,9,0,0,0,0,0,0,0,0,1,1,1
data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
return
I'm making a bunch of spheres, and therefore I need a bunch of variables to define their position if I want to interact with them. I figure there must be a way to create unique variable names to go along with the unique spheres I'm creating. I want DBPro to automatically create them for me.
So as NewObjects are created, variables specific to each object are also created. If NewObject=1, then it creates x1#=value, y1#=value, and z1#=value; if NewObject=12, then it creates x12#=value, y12#=value, z12#=value.
I want to use for/next commands to define and write only the variables I need. The alternative that I see for this is to plan how many spheres I want to have, and copy and paste the same code over and over again with the only difference being adding a different number after the x,y,z to define a specific variable for a specific sphere. This method I have will work if only there was a way to name a variable using another variable.
EDIT: Updated code