Home - Forums - Documentation - Gallery - Bugs
(Example)
(Example)
Line 24: Line 24:
print "movable destroyed"
print "movable destroyed"
-
movlistener = MyMovableListener
+
movlistener = MyMovableListener()
Movable.AddListener(movlistener)
Movable.AddListener(movlistener)
</pre>
</pre>

Revision as of 19:28, 4 January 2008

Contents

Introduction

There are a number of interfaces in cs and cel which can serve as callbacks to discover things happening in engine. To be able use this functionality, one must inherit from special base classes for python.

There are two modules in csexternal repository that provide such classes, one for cs and one for cel: cscallback and celcallback.

In general for a given interface, there is a base class, with the naming convention of prefixing with py instead of i as is normal for interfaces.

Example

For example, in iMovableListener this would be pyMovableListener. And to use it just declare your class inheriting from this, and implement the needed functions in interface from python:

from cscallback import pyMovableListener

class MyMovableListener(pyMovableListener):
    # constructor
    def __init__(self):
        pyMovableListener.__init__(self,ObjectRegistry)
    # callback functions
    def MovableChanged(movable):
        print "movable changed"
    def MovableDestroyed(movable):
        print "movable destroyed"

movlistener = MyMovableListener()
Movable.AddListener(movlistener)

Note how the constructor for all callback classes requires that you pass the object registry (in the previous example, it is assumed ObjectRegistry is the object registry, and Movable a valid movable).

Supported interfaces

cscallback

iMissingLoaderData
iTerrainCellHeightDataCallback
iTerrainCellLoadCallback
iParticleEmitter
iParticleEffector
iSkeletonBoneUpdateCallback
iSkeletonAnimationCallback
iSkeletonUpdateCallback
iMeshObjectDrawCallback
iObjectModelListener
iObjectNameChangeListener
iProcTexCallback
iODEFrameUpdateCallback
iReporterListener
iStandardReporterListener
iDynamicsStepCallback
iDynamicsMoveCallback
iDynamicsCollisionCallback
iDynamicsColliderCollisionCallback
iOffscreenCanvasCallback
iVisibilityCullerListener
iLightCallback
iPortalCallback
iCameraSectorListener
iEngineFrameCallback
iEngineSectorCallback
iSectorCallback
iSectorMeshCallback
iLightVisibleCallback
iMeshDrawCallback
iTextureCallback
iMovableListener
iSndSysStreamCallback
iSndSysRendererCallback
iSndSysListener
iSndSysListenerDoppler

celcallback

iQuestTriggerCallback
iQuestSequenceCallback
iCelNewEntityCallback
iCelEntityRemoveCallback
iCelTimerListener
iPcInventoryListener
iPcTriggerListener
iPcSoundListener
iPcPropertyListener
iPcMeshSelectListener
iPcGravityCallback

Back to PyCrystal

| Article | Discussion | View source | History |