i am having problems with this, how can i load the data from file so when i try to save that same data or modified data it saves same way as original
this is piece my save code - it is quite a large function
function SaveMap(map$)
GameDir$=dir exe()
cd GameDir$
if file exist(map$)=1 then delete file map$
num=12
`store map data
map=find free file()
open to write map,map$
`store three sided brushes
for i=12 to 1012
if object exist(i+1)=1
inc num,1
write string map,"["+str$(num)+"]"
write string map,"Brush="+str$(i+1)
write string map,"Model="+BrushModel3$
write string map,"Texture="+limb texture name(i+1,0)
`write string map,"Material="+MatBrush3$
write string map,"PosX="+str$(object position x(i+1))
write string map,"PosY="+str$(object position y(i+1))
write string map,"PosZ="+str$(object position z(i+1))
write string map,"AngX="+str$(object angle x(i+1))
write string map,"AngY="+str$(object angle y(i+1))
write string map,"AngZ="+str$(object angle z(i+1))
write string map,"ScaleX="+str$(object scale x(i+1))
write string map,"ScaleY="+str$(object scale y(i+1))
write string map,"ScaleZ="+str$(object scale z(i+1))
endif
next i
...
and this is my load code
`load map/level
function LoadMap(file$)
GameDir$=dir exe()
`return to the root game folder
cd GameDir$
WriteLog("Loading map")
AddConsole("Loading map")
`prepare for loading
`delete editor brushes
DeleteAll()
`flush video memory
CleanUpGfx()
`load editor brushes
LoadBrushes()
`reset all values
ZeroAll()
`load map file -> get map data
if file exist(file$)=1
mapfile=find free file()
SecNum=0
`get total number of objects in the map
open to read mapfile,file$
repeat
read string mapfile,s$
if left$(s$,1)="["
inc SecNum,1
endif
until file end(mapfile)=1
`report number of objects in the map
WriteLog("Number of objects: "+str$(SecNum))
`if there is no objects
if SecNum=0
WriteLog("Empty map")
exitfunction
endif
`if there is full capacity of three sided brushes
`if SecNum>1000
` WriteWarning("Maximum number of objects found")
`endif
close file mapfile
`process map data
for i=13 to 12+SecNum
if file end(mapfile)=1 then goto exitlog
`process all brushes
`get data for each brush object
BrushObj$=GetString(file$,str$(i),"Brush")
BrushModel$=GetString(file$,str$(i),"Model")
BrushTexture$=GetString(file$,str$(i),"Texture")
BrushPosX$=GetString(file$,str$(i),"PosX")
BrushPosY$=GetString(file$,str$(i),"PosY")
BrushPosZ$=GetString(file$,str$(i),"PosZ")
BrushAngX$=GetString(file$,str$(i),"AngX")
BrushAngY$=GetString(file$,str$(i),"AngY")
BrushAngZ$=GetString(file$,str$(i),"AngZ")
BrushScaleX$=GetString(file$,str$(i),"ScaleX")
BrushScaleY$=GetString(file$,str$(i),"ScaleY")
BrushScaleZ$=GetString(file$,str$(i),"ScaleZ")
`convert data to integer values
BrushObj#=intval(BrushObj$)
`if BrushObj#=14 or BrushObj#>14 then inc brush3,1
`if BrushObj#=1014 or BrushObj#>1014 then inc brush4,1
BrushPosX#=intval(BrushPosX$)
BrushPosY#=intval(BrushPosY$)
BrushPosZ#=intval(BrushPosZ$)
BrushAngX#=intval(BrushAngX$)
BrushAngY#=intval(BrushAngY$)
BrushAngZ#=intval(BrushAngZ$)
BrushScaleX#=intval(BrushScaleX$)
BrushScaleY#=intval(BrushScaleY$)
BrushScaleZ#=intval(BrushScaleZ$)
`load object
load object "base/"+BrushModel$,BrushObj#
position object BrushObj#,BrushPosX#,BrushPosY#,BrushPosZ#
rotate object BrushObj#,BrushAngX#,BrushAngY#,BrushAngZ#
scale object BrushObj#,BrushScaleX#,BrushScaleY#,BrushScaleZ#
`texture object
TexImg=find free image()
load image BrushTexture$,TexImg
texture object BrushObj#,TexImg
remstart
`load collision objects
`if object is three sided brush
if BrushObj#>=13 and BrushObj#<=1012
MakeBrush3Collision(BrushPosX#,BrushPosY#,BrushPosZ#,BrushScaleX#,BrushScaleY#,BrushScaleZ#,BrushAngX#,BrushAngY#,BrushAngZ#,0)
endif
`if object is four sided brush
if BrushObj#>=1013 and BrushObj#<=100012
MakeBrush4Collision(BrushPosX#,BrushPosY#,BrushPosZ#,BrushScaleX#,BrushScaleY#,BrushScaleZ#,BrushAngX#,BrushAngY#,BrushAngZ#,0)
endif
remend
next i
exitlog:
`return to the root game folder
cd GameDir$
WriteLog("map loaded successfully")
AddConsole("map loaded successfully")
endif
`report number of brushes and entities in the map
endfunction
so now the problem is when i load my map, that was saved with
[13]
Brush=1014
Model=models/editor/4_sided_brush.x
Texture=textures/detail/metalfine.dds
PosX=0
PosY=0
PosZ=0
AngX=0
AngY=0
AngZ=0
ScaleX=500
ScaleY=100
ScaleZ=500
and then try to save it again, i get
[13]
Brush=13
Model=models/editor/3_sided_brush.x
Texture=textures/detail/metalfine.dds
PosX=0
PosY=0
PosZ=0
AngX=0
AngY=0
AngZ=0
ScaleX=100
ScaleY=100
ScaleZ=100
[14]
Brush=1014
Model=models/editor/4_sided_brush.x
Texture=textures/detail/metalfine.dds
PosX=0
PosY=0
PosZ=0
AngX=0
AngY=0
AngZ=0
ScaleX=500
ScaleY=100
ScaleZ=500
this will crash the program with 'object already exists at line xxxx' error
can someone help me with this this is critical to any level editor?