Arrays in Types?

Blitz3D Forums/Blitz3D Beginners Area/Arrays in Types?

Jellon(Posted 2004) [#1]
I've checked all over documentations and examples and all sorts of places, but I don't see any examples of using placing an arary in a Type Field. The compliler won't let me do it either. Am I wrong, or is there some way to accomplish this without using a bank? I don't like using the peek/poke commands honestly, and beyond that, I want to create an array that holds types in a type.
Example:
Type Skill
	Field name$,Damage#,Img3D
End Type

Type Creature
	;I want the creature to have upto 4 skills
	Field Dim Skills.Skill(4)
	Field name$,HP#,Img3D
End Type


That isn't my actual code, just an example I came up with in 1 minute ^_^
Anyhow, thanks for any help provided.


Jellon(Posted 2004) [#2]
Wait, I think I got it. You use [] instead of (). Saw it some where in someone's example code for more experianced ppl. So heres to those who didn't know you could.
Example code:
Type Container
	Field Things.Thing[20]
End Type

Type Thing
	Field Value[5]
End Type

Global Cup.Container=New Container
Cup\Things[0]=New thing
Cup\Things[0]\Value[0]=1
Cup\Things[0]\Value[1]=2
Cup\Things[0]\Value[2]=3
Cup\Things[1]=New thing
Cup\Things[1]\Value[0]=4
Cup\Things[1]\Value[1]=5
Cup\Things[1]\Value[2]=6

For T=0 To 1
	For V=0 To 2
		Print Cup\Things[T]\Value[V]
	Next
Next
WaitKey()
End



Picklesworth(Posted 2004) [#3]
With arrays in types, you can't change the size of an array though.


Ross C(Posted 2004) [#4]
And, they can only be one dimensional :o)


Techlord(Posted 2004) [#5]
And, they can only be one dimensional :o)

True. However, with a simple math formula you can simulate Multi-dimensional Arrays of any size.