type and field question

Blitz3D Forums/Blitz3D Beginners Area/type and field question

Santiworld(Posted 2009) [#1]
hi, i want to make something like this, can i?
type race
  field laps
  field cars
  field positiones[laps,cars]   <--- ???  blitz say error :)
  field time_lap[laps,cars]  
end type


i want to record the position of all cars in each lap of the race..


Mortiis(Posted 2009) [#2]
Blitz arrays cannot be multi-dimensional.


Santiworld(Posted 2009) [#3]
:(

in a type neither i can't use field positiones ( cars, laps ) ?


Charrua(Posted 2009) [#4]
hi

you are using blitz arrays (declraded with [] ) and as the help says:
"They cannot be multi-dimensional, and cannot be resized."

the error is for that, i think.

try

type lap
field number
field positiones[cars] <--- ??? blitz say error :)
field time_lap[cars]
end type

and do a list of lap's
(with the lap number and time for each car and position for each car)

Should work

or:

laps.lap[NumberOfLaps]
an array of type lap with NumberOfLaps elements

Juan


Warner(Posted 2009) [#5]
yes, instead use:
positiones( cars * max_number_of_laps + laps )

or

positiones( laps * max_number_of_cars + cars )


Santiworld(Posted 2009) [#6]
:) thanks!


John Blackledge(Posted 2009) [#7]
You _can_ have arrays within arrays, eg:
Type Jseq
	Field name$
	Field startframe
	Field endframe
End Type

Const nMaxCharSeqs = 10

Type JChar
	Field label$
	Field seq.Jseq[nMaxCharSeqs]
End Type

Global nNumChars = 10
Dim char.JChar(nNumChars)

For z = 0 To nNumChars
	char(z) = New JChar
	For cnt = 0 To nMaxCharSeqs
		char(z)\seq.Jseq[cnt] = New Jseq
	Next
Next

; accessed through:
; char(num)\seq[z]\name$



_PJ_(Posted 2009) [#8]
Not sure if it's better/worse or anything, but couldnt the positions/laps be stored with a separate type?

type lap
field lap_number
field time
field positon
end type

type race
  field car
  field laps.lap
end type



John Blackledge(Posted 2009) [#9]
Yes, but again, see my definition above and adapt it to your own needs.