[Bf-committers] A patch to add an addObject() method to KX_Scene

Campbell Barton ideasman42 at gmail.com
Sun Feb 22 05:14:58 CET 2009


On Sat, Feb 21, 2009 at 7:48 PM, José Ignacio <jose.cyborg at gmail.com> wrote:
> On Sun, Feb 22, 2009 at 12:37 AM, Mitchell Stokes <mitchell at daboys4u.com> wrote:
>> I've created a patch to add an addObject() method to KX_Scene so that
>> I could avoid using the add object actuator.
>>
>> Here's the link to the tracker entry:
>> http://projects.blender.org/tracker/index.php?func=detail&aid=18309&group_id=9&atid=306
>>
>> The following is the description that's in the tracker:
>>
>> I got tired of using the Add Object Actuator, so I added an
>> addObject() method to KX_Scene. Here is it's PyDoc entry:
>>
>> def addObject(object, other, time=0)
>>        """
>>        Adds an object to the scene like the Add Object Actuator would.
>>
>>        @param object: The object to add
>>        @type object: L{KX_GameObject} or string
>>        @param other: The object's center to use when adding the object
>>        @type other: L{KX_GameObject} or string
>>        @param time: How long (in seconds) that the new object will live
>
> Fix:
>        @param time: How long (in seconds) that the new object will
> live, 0 meaning unlimited.
>
>>        @type time: int
>>        """
>>
>> An example:
>>
>> gl = GameLogic
>> own = gl.getCurrentController().getOwner()
>> scene = gl.getCurrentScene()
>>
>> ob = scene.addObject("Cube", own)
>>
>> print ob.name
>
> ^ ^
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
>

+1 since its really useful.
Though I wonder if this is a good direction to head - where python
replicates actuator functionality for convenience. - Benoit? - what do
you think?

-- 
- Campbell


More information about the Bf-committers mailing list