Passing type to function?

Blitz3D Forums/Blitz3D Beginners Area/Passing type to function?

ralphy(Posted 2004) [#1]
How do I pass and return a type to a function?
In the following code can you let me know the correct syntax where I have put the ??????'s.

Cheers in advance for any help.
Ralphy

Type enemy
Field id
Field xpos#
Field ypos#
Field waypoint_path
Field frame
End Type

Function UpdateEnemy()
For baddies.enemy = Each enemy
FollowWaypoints(baddies.enemy)?????
Next
End Function

Function FollowWaypoints(.enemy)?????
....
return enemy??????
End Function


_PJ_(Posted 2004) [#2]
Because you are using the For/Each loop, your function will work for ALL your 'enemy' type objects. I think you need to set a Field to represent your enemies (either an image/meshhandle or something) and operate your FollowWaypoints function on the object.

FollowWaypoints(baddies\mesh)

Function FollowWaypoints(meshhandle)

or something (If Ive understood correctly)


Matty(Posted 2004) [#3]
Function FollowWaypoints.Enemy(VariableName.Enemy)
;Variablename could be anything...
;do your stuff in here..
;
;
return VariableName.Enemy
end function


ralphy(Posted 2004) [#4]
Cheers Matty.
That now compiles a treat!