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.
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user