Ok, so here's what I have so far.
if keystate(60) //F2
if file exist("media\Mountains of Snow\verts\myter.txt") = 1 then delete file "media\Mountains Of Snow\verts\myter.txt"
if file exist("media\Mountains of Snow\verts\myter_debug.txt") = 1 then delete file "media\Mountains Of Snow\verts\myter_debug.txt"
open to write 1, "media\Mountains Of Snow\verts\myter.txt"
open to write 2, "media\Mountains Of Snow\verts\myter_debug.txt"
for x = 0 to BT GetSectorCount(1, 0) - 1
if file exist("media/Mountains Of Snow/verts/terrain_vert"+str$(x+1)+".dbo") then delete file "media/Mountains Of Snow/verts/terrain_vert"+str$(x+1)+".dbo"
BT MakeSectorObject 1, 0, x, x+499
xp$ = str$(BT GETSECTORPOSITIONX(1, 0, x))
yp$ = str$(BT GETSECTORPOSITIONY(1, 0, x))
zp$ = str$(BT GETSECTORPOSITIONZ(1, 0, x))
save object "media/Mountains Of Snow/verts/terrain_vert"+str$(x+1)+".dbo", x+499
if file exist("media/Mountains Of Snow/verts/terrain_vert"+str$(x+1)+".dbo")
xpos#=val(xp$)
ypos#=val(yp$)
zpos#=val(zp$)
objnum = x+1
write string 1, str$(objnum)
write string 1, xp$
write string 1, yp$
write string 1, zp$
write string 2, "Object "+str$(x+1)+" Coordinates"
write string 2, "================================"
write string 2, str$(xpos#)
write string 2, str$(ypos#)
write string 2, str$(zpos#)
write string 2, "================================"
write string 2, ""
endif
next x
close file 1
close file 2
open to read 1, "media\Mountains Of Snow\verts\myter.txt"
for x = 0 to BT GetSectorCount(1, 0) - 1
read string 1, on$
read string 1, xp$
read string 1, yp$
read string 1, zp$
objnum=val(on$)
xpos#=val(xp$)
ypos#=val(yp$)
zpos#=val(zp$)
if object exist(objnum) = 0 then load object "media/Mountains Of Snow/verts/terrain_vert"+str$(x+1)+".dbo", objnum
position object objnum, xpos#, ypos#+1500, zpos#
set object cull objnum, 0
Color Object objnum, rgb(128, 128, 128)
next x
close file 1
endif
EDIT: I've included what each line (at least what I THINK) is doing:
`If I press F2
if keystate(60) //F2
`If either of the data files ALREADY exist, delete them
if file exist("media\Mountains of Snow\verts\myter.txt") = 1 then delete file "media\Mountains Of Snow\verts\myter.txt"
if file exist("media\Mountains of Snow\verts\myter_debug.txt") = 1 then delete file "media\Mountains Of Snow\verts\myter_debug.txt"
`Otherwise, open them for writing
open to write 1, "media\Mountains Of Snow\verts\myter.txt"
open to write 2, "media\Mountains Of Snow\verts\myter_debug.txt"
`For EACH sector starting from 0 to the Sector count - 1
for x = 0 to BT GetSectorCount(1, 0) - 1
`if the sector file ALREADY exists then delete them
if file exist("media/Mountains Of Snow/verts/terrain_vert"+str$(x+1)+".dbo") then delete file "media/Mountains Of Snow/verts/terrain_vert"+str$(x+1)+".dbo"
`make a sector object, with the ID of the sector object + 499
BT MakeSectorObject 1, 0, x, x+499
`get the sector position coordinates
xp$ = str$(BT GETSECTORPOSITIONX(1, 0, x))
yp$ = str$(BT GETSECTORPOSITIONY(1, 0, x))
zp$ = str$(BT GETSECTORPOSITIONZ(1, 0, x))
`save EACH sector object
save object "media/Mountains Of Snow/verts/terrain_vert"+str$(x+1)+".dbo", x+499
`if the sector file exists then
if file exist("media/Mountains Of Snow/verts/terrain_vert"+str$(x+1)+".dbo")
`translate the sector position coordinates into floats
xpos#=val(xp$)
ypos#=val(yp$)
zpos#=val(zp$)
`get the object number of each sector
objnum = x+1
`write the object numbers, and sector coordinates to the file
write string 1, str$(objnum)
write string 1, xp$
write string 1, yp$
write string 1, zp$
`write the object numbers, and sector coordinates to the DEBUG file with a bit of extra info
write string 2, "Object "+str$(x+1)+" Coordinates"
write string 2, "================================"
write string 2, str$(xpos#)
write string 2, str$(ypos#)
write string 2, str$(zpos#)
write string 2, "================================"
write string 2, ""
endif
next x
`close both files from writing
close file 1
close file 2
`open the data file for reading
open to read 1, "media\Mountains Of Snow\verts\myter.txt"
`for EACH sector - 1 starting at index(0)
for x = 0 to BT GetSectorCount(1, 0) - 1
`read each string from the file
read string 1, on$
read string 1, xp$
read string 1, yp$
read string 1, zp$
`translate the coordinates and object number to floats
objnum=val(on$)
xpos#=val(xp$)
ypos#=val(yp$)
zpos#=val(zp$)
`if the object does NOT exist in memory, then load it
if object exist(objnum) = 0 then load object "media/Mountains Of Snow/verts/terrain_vert"+str$(x+1)+".dbo", objnum
`position EACH sector object, at their specified X, Y, and Z values
position object objnum, xpos#, ypos#+1500*x, zpos#
`Cull the object so we can see it
set object cull objnum, 0
`Color the object so we can see it
Color Object objnum, rgb(128, 128, 128)
next x
`Close the main file from reading
close file 1
endif
CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!