[Bf-committers] Using GameObject IDs when calling from Python, or changing names of added objects?

Toni Alatalo bf-committers@blender.org
Tue, 16 Sep 2003 10:43:50 +0300


On Monday, September 15, 2003, at 07:52 PM, Patrick wrote:

> The most obvious thing to me would instead of a setName actuator, to 
> automatically keep names unique the same way they are in blender 
> normally.  If that name exists already, incremement the end by .001.  
> I'm not sure how possible this is with added objects, if they aren't 
> "true" blender objects that

Thanks for the thought, that's what I tried to mean with the third 
option at the end of my post (where mentioned sequencing) -- was 
thinking about a problem with it later:

As the actuators (such as addObject) are not actually run when called, 
but added to the list of things to do for the game engine for the next 
time it does it's thing, could the actuator still somehow return the 
new unique name it gave (or will give?) to the added object?

For example, if there are several different gameobjects with addobject 
actuators, and they are used independently to add copies of the same 
original object, possibly during the same game engine cycle, it is not 
obvious when calling the actuator what the name will become. Of course 
some solution for working that out could be made, will think about it 
and also check if there are any actuators that return something when 
have time..

(in my current program on the Python side I deal with that problem so 
that there is only one object with an addObject actuator, and when it's 
used a value is stored to a registry telling which object was created, 
and when the object is later actually added by the engine it runs an 
initialisation script that tells the program what gameobject it 
became.. oh and if several objects are added by one command they are 
all queued to be added using that single actuator one per game engine 
cycle..)

So hopefully there is a good way to return the name, of course this 
approach could be tried out first even without (not doing simultaneous 
adding of the same object and keeping a similar count in Python in sync 
to get the right reference, for example?).

~Toni