forked from bartvdbraak/blender
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:
parent
ab7794392e
commit
6a3e8e7fff
@ -1703,7 +1703,7 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh
|
||||
}
|
||||
|
||||
uiDefButI(block, NUM, 0, "Blendin: ", xco+30, yco-64, (width-60)/2, 19, &aa->blendin, 0.0, MAXFRAMEF, 0.0, 0.0, "Number of frames of motion blending");
|
||||
uiDefButS(block, NUM, 0, "Priority: ", xco+30+(width-60)/2, yco-64, (width-60)/2, 19, &aa->priority, 0.0, 100.0, 0.0, 0.0, "Execution priority - lower numbers will override actions with higher numbers");
|
||||
uiDefButS(block, NUM, 0, "Priority: ", xco+30+(width-60)/2, yco-64, (width-60)/2, 19, &aa->priority, 0.0, 100.0, 0.0, 0.0, "Execution priority - lower numbers will override actions with higher numbers, With 2 or more actions at once, the overriding clannels must be lower in the stack");
|
||||
|
||||
uiDefBut(block, TEX, 0, "FrameProp: ",xco+30, yco-84, width-60, 19, aa->frameProp, 0.0, 31.0, 0, 0, "Assign this property this actions current frame number");
|
||||
|
||||
|
@ -232,6 +232,7 @@ PyMethodDef SCA_PythonController::Methods[] = {
|
||||
METH_VARARGS, SCA_PythonController::GetSensor_doc},
|
||||
{"getScript", (PyCFunction) SCA_PythonController::sPyGetScript, METH_VARARGS},
|
||||
{"setScript", (PyCFunction) SCA_PythonController::sPySetScript, METH_VARARGS},
|
||||
{"getState", (PyCFunction) SCA_PythonController::sPyGetState, METH_VARARGS},
|
||||
{NULL,NULL} //Sentinel
|
||||
};
|
||||
|
||||
@ -442,4 +443,12 @@ PyObject* SCA_PythonController::PySetScript(PyObject* self,
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
/* 1. getScript */
|
||||
PyObject* SCA_PythonController::PyGetState(PyObject* self,
|
||||
PyObject* args,
|
||||
PyObject* kwds)
|
||||
{
|
||||
return PyInt_FromLong(m_statemask);
|
||||
}
|
||||
|
||||
/* eof */
|
||||
|
@ -81,6 +81,7 @@ class SCA_PythonController : public SCA_IController
|
||||
KX_PYMETHOD_DOC(SCA_PythonController,GetActuators);
|
||||
KX_PYMETHOD(SCA_PythonController,SetScript);
|
||||
KX_PYMETHOD(SCA_PythonController,GetScript);
|
||||
KX_PYMETHOD(SCA_PythonController,GetState);
|
||||
|
||||
|
||||
};
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -40,6 +40,20 @@ class KX_GameObject:
|
||||
"""
|
||||
Sets the game object's visible flag.
|
||||
|
||||
@type visible: boolean
|
||||
"""
|
||||
def getState():
|
||||
"""
|
||||
Gets the game object's state bitmask.
|
||||
|
||||
@rtype: int
|
||||
@return: the objects state.
|
||||
"""
|
||||
def setState():
|
||||
"""
|
||||
Sets the game object's visible flag.
|
||||
The bitmasks for states from 1 to 30 can be set with (1<<0, 1<<1, 1<<2 ... 1<<29)
|
||||
|
||||
@type visible: boolean
|
||||
"""
|
||||
def setPosition(pos):
|
||||
|
@ -46,4 +46,12 @@ class SCA_PythonController(SCA_IController):
|
||||
|
||||
@type script: string.
|
||||
"""
|
||||
def getState():
|
||||
"""
|
||||
Get the controllers state bitmask, this can be used with the GameObject's state to test if the the controller is active.
|
||||
This for instance will always be true however you could compare with a previous state to see when the state was activated.
|
||||
GameLogic.getCurrentController().getState() & GameLogic.getCurrentController().getOwner().getState()
|
||||
|
||||
@rtype: int
|
||||
"""
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user