diff options
author | Campbell Barton <ideasman42@gmail.com> | 2008-06-30 01:52:23 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2008-06-30 01:52:23 +0400 |
commit | 6a3e8e7fff4e577bea02966546293760c19deec7 (patch) | |
tree | 1b5033f3a49fba5443d6413c700862b1e8b17540 /source/gameengine/Ketsji | |
parent | ab7794392e9708ddbba24d9b444f61c06b19099b (diff) |
BGE python api addition, GameObject get/setState and Controller.getState()
Also added a note in the tooltip for action priority when using more then 1 action at a time.
Diffstat (limited to 'source/gameengine/Ketsji')
-rw-r--r-- | source/gameengine/Ketsji/KX_GameObject.cpp | 35 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_GameObject.h | 2 |
2 files changed, 37 insertions, 0 deletions
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index fd06b223216..b7750e68e8f 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -804,6 +804,8 @@ void KX_GameObject::Suspend(void) PyMethodDef KX_GameObject::Methods[] = { {"setVisible",(PyCFunction) KX_GameObject::sPySetVisible, METH_VARARGS}, {"getVisible",(PyCFunction) KX_GameObject::sPyGetVisible, METH_VARARGS}, + {"setState",(PyCFunction) KX_GameObject::sPySetState, METH_VARARGS}, + {"getState",(PyCFunction) KX_GameObject::sPyGetState, METH_VARARGS}, {"alignAxisToVect",(PyCFunction) KX_GameObject::sPyAlignAxisToVect, METH_VARARGS}, {"setPosition", (PyCFunction) KX_GameObject::sPySetPosition, METH_VARARGS}, {"getPosition", (PyCFunction) KX_GameObject::sPyGetPosition, METH_VARARGS}, @@ -1117,6 +1119,39 @@ PyObject* KX_GameObject::PyGetVisible(PyObject* self, return PyInt_FromLong(m_bVisible); } +PyObject* KX_GameObject::PyGetState(PyObject* self, + PyObject* args, + PyObject* kwds) +{ + int state = 0; + state |= GetState(); + return PyInt_FromLong(state); +} + +PyObject* KX_GameObject::PySetState(PyObject* self, + PyObject* args, + PyObject* kwds) +{ + int state_i; + unsigned int state = 0; + + if (PyArg_ParseTuple(args,"i",&state_i)) + { + state |= state_i; + if ((state & ((1<<30)-1)) == 0) { + PyErr_SetString(PyExc_AttributeError, "The state bitfield was not between 0 and 30 (1<<0 and 1<<29)"); + return NULL; + } + SetState(state); + } + else + { + return NULL; + } + Py_Return; +} + + PyObject* KX_GameObject::PyGetVelocity(PyObject* self, PyObject* args, diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 682b339bf62..89f4cb396d1 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -720,6 +720,8 @@ public: KX_PYMETHOD(KX_GameObject,SetOrientation); KX_PYMETHOD(KX_GameObject,GetVisible); KX_PYMETHOD(KX_GameObject,SetVisible); + KX_PYMETHOD(KX_GameObject,GetState); + KX_PYMETHOD(KX_GameObject,SetState); KX_PYMETHOD(KX_GameObject,AlignAxisToVect); KX_PYMETHOD(KX_GameObject,SuspendDynamics); KX_PYMETHOD(KX_GameObject,RestoreDynamics); |