Reading xyz values from a file

Blitz3D Forums/Blitz3D Programming/Reading xyz values from a file

asdfasdf(Posted 2005) [#1]
I'm trying to make a file contain xyz values that will put lights at certain positions. The way I'm doing isn't working because it doesn't position it properly.
x# = Left$(command$,Instr(command$,",") - 1)
y# = Mid$(command$,Len(x#),Instr(command$,","))
z# = Mid$(command$,Len(y#) + 1)



Snarkbait(Posted 2005) [#2]
Why don't you just use Write/ReadFloat to the file?

p.s. the reason what you have isn't working is because of the Len(x#) I believe.


Clarks(Posted 2005) [#3]
hmmm youre trying to get the length of a float len(x#), isnt it suppose to be a string.


Matty(Posted 2005) [#4]

type LightStruct

field x#,y#,z#
field r,g,b
end type 
function WriteLightFile(Filename$)
outfile=writeilfe(filename$)
if outfile=0 then runtimeerror("File Could Not Be Written:"+Filename$)

for light.lightstruct=each lightstruct
writefloat outfile,light\x
writefloat outfile,light\y
writefloat outfile,light\z
writebyte outfile,light\r
writebyte outfile,light\g
writebyte outfile,light\b

next

closefile outfile
end function

function ReadLightFile(FileName$)
infile=readfile(FileName$)
if infile=0 then runtimeerror("Could not open file:"+FileName$)
while not(eof(infile))
light.lightstruct=new lightstruct
light\x=readfloat(infile)
light\y=readfloat(infile)
light\z=readfloat(infile)
light\r=readbyte(infile)
light\g=readbyte(infile)
light\b=readbyte(infile)



wend


closefile infile
end function





Damien Sturdy(Posted 2005) [#5]
What Clarks says is true.

Use strings instead of floats.


asdfasdf(Posted 2005) [#6]
Well it was kind like a file that you could have ship data in them. I want it to be like a text file with functions.
ex.
ShipName(Mesabi Miner)
ShipFile(Mesabi Miner.3ds)
Owner(Interlake Steamship Co.)
Type(Bulk)
CabViewFile(cabview.fbf)
HornFile(horn.wav)
BoomFile(Boom.3ds)
BoomLength(52)
BoomPos()
BoomSpeed(50)
BoomLight(10,-0.5,1)
BoomLight(20,-0.5,1)
BoomLight(30,-0.5,1)
BoomLight(40,-0.5,1)
LightColor(255,0,0)
BoomLight(40,-1,1)
Light(-38,-8,9)
LightColor(0,255,0)
Light(-38,7,9)
LightColor(255,255,255)
Light(92,0,11)
BowThrusters(True)
SternThrusters(True)
HoldCrane(Hold Crane.3ds)
Propellers(2)
Length(1004)
Depth(105)
Capacity(63300)
EngineType(Diesel)
EngineHorse(16000)
ServiceSpeed(15)
MaxSpeed(30)
WaterPump(0,0,0)
ShipTie(85.5,4,7.5)
Hatch(-5.8,0,4)
Hatch(-1.5,0,4)
Hatch(2.9,0,4)
Hatch(7.3,0,4)
Hatch(11.8,0,4)
Hatch(16,0,4)
Hatch(20.8,0,4)



Clarks(Posted 2005) [#7]
be a little bit more specific


asdfasdf(Posted 2005) [#8]
I'm trying to be able to have gamers customize and add new ships without writing a program to convert it to the float values.