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

Thomas Dyar bf-committers@blender.org
Tue, 16 Sep 2003 07:14:27 -0400

At 10:43 AM 9/16/2003 +0300, you wrote:
>On Monday, September 15, 2003, at 07:52 PM, Patrick wrote:
>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?

Just not possible with the current setup, since the actuator could get 
destroyed before it runs, but after you "activate" it. What if you could 
get the name when you call getLastCreatedObject() on the actuator the next 
logic cycle? Is it too late then? This could be done with a sequencer like 
you mentioned. I think the main method that needs to be called is 
scene->m_mapStringToGameObjects.insert(mn,gameobj); The name needs to be 
chosen first, and this could be done by trying names based on the original 
object until one was found that wasn't being used yet. This would be bad 
when many objects were added, but you could make it more sophisticated later.

>(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..)

Seems like you could have several actuators called each logic cycle, since 
each keeps its own "lastcreatedobject" reference. Just store the name of 
the actuator in the registry, also.

There was also the suggestion that a "sub-cycle" of the game engine be run 
to handle ONLY newly added objects. Could be run without rendering, so new 
objects could be initialized. Then the name given the object (by the game 
engine or by a newName function) could be placed in the trackto actuator on 
the next full cycle.