passing variables into functions in type

BlitzMax Forums/BlitzMax Beginners Area/passing variables into functions in type

I have data stored in a file regarding object placement eg player start position

When I want to create that player I have a function within a type which I will then pass the variables into the player that I am creating like so (obviously nowhere near complete yet!):

Type TPlayerShip Extends TSpaceObject

	Global List:TList
	Global Image:TImage
		
	Function Create(i,x,y)
	
	Local Ship:TPlayerShip = New TPlayerShip	 
                'this is where I use the i,x,y variables

		If List = Null List = CreateList()
		List.AddLast Ship 'Add Ship Last in List
	
	EndFunction

End Type


With the variables in the brackets for the create function I get a 'missing type specifier' error. What am I doing wrong please?

Thanks
Graham

I guess you're using superstrict so need...
Function create(i:int,x:int,y:Int)


thanks,Ive added that as you suggest (am using superstrict)

now the error says 'Overriding method differs by type'

what does this mean please?

here is my code

'Spaceobject
Type TSpaceObject

	Field x#,y#
	Field XSpeed#,YSpeed#
	Field dir#
	
	Function Create() EndFunction
	
	Function UpdateAll() EndFunction
	
	Method New() EndMethod
	
	Method Update() EndMethod

	Method Destroy() EndMethod

	Method Draw() EndMethod

End Type


'PlayerShip
Type TPlayerShip Extends TSpaceObject

	Global List:TList
	Global Image:TImage
		
	Function Create(i:Int,x:Int,y:Int)
	
	Local Ship:TPlayerShip = New TPlayerShip	 
		If List = Null List = CreateList()
		List.AddLast Ship 'Add Ship Last in List
	
	EndFunction
	


End Type



Your TPlayerShip Create() function takes parms while your SpaceObject Create() does not.
You might also want to check the forum codes for posting code (e.g. look for 'code' and 'codebox')

well spotted ! thanks for your replies

ok then , can you please advise as to why I get 'identifier ship not found' error?

'PlayerShip
Type tship Extends TSpaceObject

	Global List:TList
	Global image:TImage
		
	Function Create(a:Int,b:Int,c:Int)
	'hopefully get x and y from level data
		
		Local Ship:tship = New tship	 'create the ship
			If List = Null List = CreateList() 'create the list if not already exist
			List.AddLast Ship 'Add Ship Last in List
			
		Ship.x=b 'set x and y position of ship
		Ship.y=c
		If not Image
			Image=LoadImage("gfx\player.png")
		End If
	EndFunction
	
	Method Update()
		
		Draw()
		'get player input, movement etc
		
	End Method

Method Draw()
	DrawImage(Image,x,y) 'draw image on screen at x,y
End Method

	Function UpdateAll()
		For Ship:tship = EachIn List
			Ship.Update()
		Next
	EndFunction
	
End Type


Ship is a variable that needs to be initalized as local or global.

Because you forgot to declare it.

Use for local Ship:TShip = eachin List