Okay so I am loading back an array with the following code,
if file exist("files\private\arrayDAT\plots.txt") = 1
open to read 1,"files\private\arrayDAT\plots.txt"
for a = 0 to tilesX
read float 1,cityArray().tileX
read float 1,cityArray().tileY
read float 1,cityArray().plotNumber
read float 1,cityArray().plotType
read float 1,cityArray().occupied
next a
close file 1
endif
How do I insert those values back into the array?
Whole code if needed,
Rem Project: eCity Prototype
Rem Created: Wednesday, June 30, 2010
Rem ***** Main Source File *****
sync on
sync rate 60
startBlue "",""
global r
r = make vector2(1)
r = make vector2(2) : `Base vectors
r = make vector2(3) : `Temp vector
r = make vector2(4) : `Temp vector
`Initialize the base vectors
set vector2 1, 40, -20
set vector2 2, -40, -20
`Define origin
global oX
global oY
oX = screen width() / 2
oY = screen height() / 4 * 3 + 100
`Draw
global TilesX
global TilesY
TilesX = 10
TilesY = 9
global plotno
global plotx
global ploty
global plottilex
global plottiley
global plottype `Plot Types: (1) Residential | (2) Business | (3) Industry | (Other) Image number of special building.
global plotstage `Plot Stages: (1) Plotted | (2) Built (Make building number 2 soon.)
global plotpopulation
global plottaxes
global plotattraction `Does this bring in any tourist or residents?
global plotpowered `This variable and the three below do not matter until next version. ;)
global plotwatered
global plotnearstreet
global plotstreetdemand
plotno = 3
type CityType
tileX as float
tileY as float
plotNumber as float
plotType as float
occupied as float
endtype
dim CityArray(10,10) as CityType
open to read 1,"files\setup.txt"
read string 1,experience$
read string 1,level$
read string 1,money$
read string 1,mayor$
read string 1,cityname$
global experience
global level
global money
global mname$
global cname$
experience = val(experience$)
level = val(level$)
money = val(money$)
mname$ = mayor$
cname$ = cityname$
close file 1
if file exist("files\private\TownHall.xy") = 1
open to read 1,"files\private\TownHall.xy"
read string 1,thallx$
read string 1,thally$
thallx = val(thallx$)
thally = val(thally$)
global thallexist
thallexist = 1
close file 1
endif
if file exist("files\private\arrayDAT\plots.txt") = 1
open to read 1,"files\private\arrayDAT\plots.txt"
for a = 0 to tilesX
read float 1,cityArray().tileX
read float 1,cityArray().tileY
read float 1,cityArray().plotNumber
read float 1,cityArray().plotType
read float 1,cityArray().occupied
next a
close file 1
endif
load image "media\plot.png",1
load image "media\property_forsale.png",2
load image "media\road.png",3
load image "media\Government.png",4
load image "media\Property.png",5
`load image "media\hud.png",6 `Use later!
backdrop off
do
cls
`paste image 6,0,0,1
hud()
drawNewGrid()
GridFunctions()
sprite 1,200,250,3
if thallexist = 1 then sprite 2,thallx,thally,4
TownHall()
if keystate(19) = 1
plot = 1
global plottype
plottype = 1
endif
if plot = 1
if plottype = 1
sprite plotno,x vector2(3),y vector2(3),2
endif
if pixelcol(plotno,1) > 0 or pixelcol(plotno,2) > 0 or SnapX > 10 or SnapX < 1 or SnapY > 10 or SnapY < 1
hide sprite plotno
else
show sprite plotno
endif
if mouseclick() = 1
plotx = x vector2(3)
ploty = y vector2(3)
global plottilex
global plottiley
plottilex = snapX
plottiley = snapY
if CityArray(plottilex,plottiley).occupied = 1 or pixelcol(plotno,1) > 0 or pixelcol(plotno,2) > 0 or SnapX > 10 or SnapX < 1 or SnapY > 10 or SnapY < 1
Message "Notification","Invalid Location"
if sprite exist(plotno) = 1 then delete sprite plotno
else
if plottype= 1
plotstage = 0
plotpopulation = 5
plottaxes = 25
plotattraction = 2
sprite plotno,plotx,ploty,2
endif
open to write 1,"files\private\plot"+str$(plotno)+".xy"
write string 1,str$(plotno)
write string 1,str$(plottype)
write string 1,str$(plotx)
write string 1,str$(ploty)
write string 1,str$(plottilex)
write string 1,str$(plottiley)
write string 1,str$(plotstage)
write string 1,str$(plotpopulation)
write string 1,str$(plottaxes)
write string 1,str$(plotattraction)
close file 1
if file exist("files\private\largestplot.sts") = 1 then delete file "files\private\largestplot.sts"
open to write 1,"files\private\largestplot.sts"
write string 1,str$(plotno)
close file 1
cityArray(plottilex,plottiley).tileX = plotilex
cityArray(plottilex,plottiley).tileY = plotiley
cityArray(plottilex,plottiley).plotNumber = plotno
cityArray(plottilex,plottiley).plotType = plottype
cityArray(plottilex,plottiley).occupied = 1
if file exist("files\private\arrayDAT\plots.txt") = 1 then delete file "files\private\arrayDAT\plots.txt"
open to write 1,"files\private\arrayDAT\plots.txt"
for c = 0 to tilesX
write float 1,cityArray().tileX
write float 1,cityArray().tileY
write float 1,cityArray().plotNumber
write float 1,cityArray().plotType
write float 1,cityArray().occupied
next c
close file 1
plotno = plotno + 1
plot = 0
endif
endif
endif
set cursor 0,0
sync
loop
end
Functions.dba shouldn't be needed...
Thanks!
Zeus