Storing object handles in EntityName - bad idea?

Blitz3D Forums/Blitz3D Beginners Area/Storing object handles in EntityName - bad idea?

octothorpe(Posted 2005) [#1]
This works, but is it a bad idea?

nameentity(u\entity, "unit" + handle(u))
;;;
mouseover_entity = camerapick(global_camera, mousex(), mousey())
if mouseover_entity then
	mouseover_entity_name = entityname(mouseover_entity)
	if left$(mouseover_entity_name, 4) = "unit" then
		u.unit_type = object.unit_type(right$(mouseover_entity_name, len(mouseover_entity_name) - 4))
I feel dirty.


DH(Posted 2005) [#2]
Not at all (as in not a bad idea). When doing camera picks you need some way to refference an arbitrary number of objects.

I have done this in the past with editors and never felt guilty about it.

Sometimes you just need to do what you have to with the tools at your disposal.


jfk EO-11110(Posted 2005) [#3]
I agree, it's a nice method. The only problem is, you need to load your map with LoadAnimMesh. This way you will have to handle your Map no longer as a single Mesh, but recursively as a hierarchy of entities (see code archives: how to use EntityAlpha with animated meshes).