Entities in types.......

Blitz3D Forums/Blitz3D Programming/Entities in types.......

Farflame(Posted 2003) [#1]
Errr, I'll try to explain what I'm trying to do, cuz I'm very confused :)

I have alot of spaceships. I'd originally stored everything in arrays but I've just discovered the joys of types, so I'm converting everything over. Storing the non-entity stuff for my ships is easy enough, for example the ships speed, target, damage etc. I understand all that fine. But I'm not sure how to store the entity itself. Is there some way to attach my entity to my type? So that when I'm playing around with one of my ships, I could also manipulate the entity? I looked at the Wingpilot sample, and that seems to do exactly this, but I'm still very confused. How would I create my ship as part of the type and then manipulate it?

I know that's not very clear, but hopefully someone will understand what I'm getting at.


Bot Builder(Posted 2003) [#2]
It's pretty simple. Your entities are stored in your program by a memory pointer. This is simply an integer so you can easily put it in a type:
type ship
 field health,shields
 field entity          ;just an integer that stores the entity handle
end type

s.ship=new ship
s\entity=createcube()



Farflame(Posted 2003) [#3]
Yeah, I thought so and I'm doing that. It must be the way I'm creating them, or calling them in my functions that's causing the problem. Thanks though, that's cleared that up at least.


Ross C(Posted 2003) [#4]
Hey,

To manipulate the ship you would need to find the one you want to work with. Then just use it like you would a normal entity.

PositionEntity e\entity,0,0