From 4cd088b1059afa2e7b998c184b2c9deecd4be4a9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 11 Apr 2009 20:58:09 +0000 Subject: BGE Py API - setting the scene attributes would always add to the scenes custom dictionary. - new CListValue method from_id(id) so you can store a Game Objects id and use it to get the game object back. ob_id = id(gameOb) ... gameOb = scene.objects.from_id(ob_id) This is useful because names are not always unique. --- source/gameengine/Ketsji/KX_Scene.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source/gameengine/Ketsji/KX_Scene.h') diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index 9f05ddf70c2..1bdfbd45d20 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -590,6 +590,27 @@ public: /* for dir(), python3 uses __dir__() */ static PyObject* pyattr_get_dir_dict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static int py_base_setattro_scene(PyObject * self, PyObject *attr, PyObject *value) + { + if (value==NULL) + return ((PyObjectPlus*) self)->py_delattro(attr); + + int ret= ((PyObjectPlus*) self)->py_setattro(attr, value); + + if (ret) { + if (!PyDict_SetItem(((KX_Scene *) self)->m_attrlist, attr, value)) { + PyErr_Clear(); + ret= 0; + } + else { + ret= -1; + } + } + + return ret; + } + + virtual PyObject* py_getattro(PyObject *attr); /* name, active_camera, gravity, suspended, viewport, framing, activity_culling, activity_culling_radius */ virtual int py_setattro(PyObject *attr, PyObject *pyvalue); -- cgit v1.2.3