Help Types

Blitz3D Forums/Blitz3D Beginners Area/Help Types

Ok I have a custom type called Player this type have 6 players. Let say i want the values of the 4.th player how do i do?
(without using After and Before)

You can use arrays in your custom types.

Dim alien_ID.alien(ALIEN_MAXCOUNT%)

alien_ID(1)=alienNew()

alien_ID(1)\x#=1.0

alienposx = alien_ID(1)\x#

myalien.alien = alien_ID(1)

;Alternative Blitz Array
Global alien_ID.alien[ALIEN_MAXCOUNT%]

alien_ID[1]=alienNew()

alien_ID[1]\x#=1.0

alienposx = alien_ID[1]\x#

myalien.alien = alien_ID[1]


Full version here http://www.hpquest.com/techlord/apps/AOBPwB3D/

i have tried with this:
Function CreateTile(number2,image2$,x2,y2,tile2)
ANTAL = ANTAL + 1
Dim newp.Tile(ANTAL)
newp.Tile(ANTAL) = New Tile
newp(ANTAL)\x# = x2*50
newp(ANTAL)\y# = y2*50
newp(ANTAL)\number = number2
newp(ANTAL)\image$ = image2$
newp(ANTAL)\tile = tile2
End Function

and later i try in code this:
Text 0,80,newp(StartNumber)\x#

Error: "Object dose not exist"
I have over 2000 tiles and it sould exist.. If i change StartNumber to 1 it wount work either please help...

If you re-dim an array, it's content gets cleared.
What you can do, is to create the tiles in CreateTile, and use another function, such as RescanTiles to assign an array to them.
Depending on how you want to use this, first you create all tiles using CreateTile, and after that, call RescanTiles once.
Note: code is not tested.
Global ANTAL
Function CreateTile(number2,image2$,x2,y2,tile2)
 ANTAL = ANTAL + 1
 newt.Tile = New Tile
 newt\x# = x2*50
 newt\y# = y2*50
 newt\number = number2
 newt\image$ = image2$
 newt\tile = tile2
End Function 

Function RescanTiles()
 Dim newp.Tile(ANTAL)
 i = 0
 For t.Tile = Each Tile
  newp(i) = t
  i = i + 1
 Next
End Function