Accessing user defined types

BlitzMax Forums/BlitzMax Beginners Area/Accessing user defined types

Ogg77777(Posted 2005) [#1]
I am trying To access a variable in a user defined Type from another user defined type.
Specifically a VehicleType Field must access the TileType Field To determine If the vehicle can enter a Tile (See simplified code below).


Type Tiles

Field TileType:Int [25, 20]

End Type


Type Vehicle

Field VehicleType:Int

End Type

Here is what I am attempting To do

If Tiles.TileType <> 1 Then
MoveVehicle()
End If

MoveVehicle() is a Method of Type Vehicle
Please give your solution using code.
Thank you For your help in this matter.


McFox(Posted 2005) [#2]
I'm not sure to understand what do you ask...

Type Tiles
	Field TileType:Int
End Type


Type Vehicle Extends Tiles
	Field VehicleType:Int
	Method MoveVehicle()
		'code here
	End Method
End Type

Global car:Vehicle = New Vehicle

If car.TileType <> 1 Then
	car.MoveVehicle()
End If



Ogg77777(Posted 2005) [#3]
Type Tiles and Type Vehicle are two unrelated types. As
the Tiles type has many more fields, not needed by the Vehicle Type, I would prefer not to extend the Vehicle type. I only need to access the TileType field of the Tiles Type from a method in the Vehicle Type to determine if an object from Type Vehicle can enter the Tile (TileType 1 is a water Tile and cannot be accessed by a vehicle object). Is this possible without extending the Type Vehicle?


Koekelas(Posted 2005) [#4]
I'm not sure I understand you but...

Type TTile
	
	Field type:Int
	
	'...
EndType

Type TVehicle
	
	'...
	
	Method move(tileType:Int)
		
		If tileType <> 1 Then
			
			'Move...
		EndIf
	EndMethod
EndType

'...

Local tile:TTile	= New TTile
Local vehicle:TVechicle	= New TVechicle

'...

vechicle.move(tile.type)

'...




Nicolas.


Tibit(Posted 2005) [#5]
Is this what you seek to do?




Ogg77777(Posted 2005) [#6]
Thanks for the help, finally got it running.