diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-04-20 01:01:12 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-04-20 01:01:12 +0400 |
commit | f5fc4ebdd8ede5263f4b34f161ebe139d40466dc (patch) | |
tree | 7122404f3410c14cd225343cfc97bc0a97441f1e /source/gameengine/GameLogic | |
parent | d78eec93197cc1d3cc9da773ce30396891ec60f6 (diff) |
BGE Python API
- More verbose error messages.
- BL_Shader wasnt setting error messages on some errors
- FilterNormal depth attribute was checking for float which is bad because scripts often expect ints assigned to float attributes.
- Added a check to PyVecTo for a tuple rather then always using a generic python sequence. On my system this is over 2x faster with an optmized build.
Diffstat (limited to 'source/gameengine/GameLogic')
6 files changed, 14 insertions, 14 deletions
diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index 28ff1c82924..1c601eded81 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -601,7 +601,7 @@ PyObject* SCA_JoystickSensor::pyattr_get_axis_single(void *self_v, const KX_PYAT SCA_Joystick *joy = self->m_pJoystickMgr->GetJoystickDevice(self->m_joyindex); if(self->m_joymode != KX_JOYSENSORMODE_AXIS_SINGLE) { - PyErr_SetString(PyExc_TypeError, "joystick sensor is not an 'Single Axis' type"); + PyErr_SetString(PyExc_TypeError, "val = sensor.axisSingle: Joystick Sensor, not 'Single Axis' type"); return NULL; } diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index d56e5fe29dc..c946156283f 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -590,7 +590,7 @@ KX_PYMETHODDEF_DOC_O(SCA_KeyboardSensor, getKeyStatus, "\tGet the given key's status (KX_NO_INPUTSTATUS, KX_JUSTACTIVATED, KX_ACTIVE or KX_JUSTRELEASED).\n") { if (!PyInt_Check(value)) { - PyErr_SetString(PyExc_ValueError, "getKeyStatus expected an int"); + PyErr_SetString(PyExc_ValueError, "sensor.getKeyStatus(int): Keyboard Sensor, expected an int"); return NULL; } @@ -598,7 +598,7 @@ KX_PYMETHODDEF_DOC_O(SCA_KeyboardSensor, getKeyStatus, if ((keycode < SCA_IInputDevice::KX_BEGINKEY) || (keycode > SCA_IInputDevice::KX_ENDKEY)){ - PyErr_SetString(PyExc_AttributeError, "invalid keycode specified!"); + PyErr_SetString(PyExc_AttributeError, "sensor.getKeyStatus(int): Keyboard Sensor, invalid keycode specified!"); return NULL; } diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp index 8f41e799b01..4dbeb156e63 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp +++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp @@ -279,7 +279,7 @@ KX_PYMETHODDEF_DOC_O(SCA_MouseSensor, getButtonStatus, if ((button < SCA_IInputDevice::KX_LEFTMOUSE) || (button > SCA_IInputDevice::KX_RIGHTMOUSE)){ - PyErr_SetString(PyExc_ValueError, "invalid button specified!"); + PyErr_SetString(PyExc_ValueError, "sensor.getButtonStatus(int): Mouse Sensor, invalid button specified!"); return NULL; } diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index 121f868a281..b8052555528 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -187,7 +187,7 @@ SCA_IActuator* SCA_PythonController::LinkedActuatorFromPy(PyObject *value) /* set the exception */ PyObject *value_str = PyObject_Repr(value); /* new ref */ - PyErr_Format(PyExc_ValueError, "'%s' not in this controllers actuator list", PyString_AsString(value_str)); + PyErr_Format(PyExc_ValueError, "'%s' not in this python controllers actuator list", PyString_AsString(value_str)); Py_DECREF(value_str); return false; @@ -417,14 +417,14 @@ PyObject* SCA_PythonController::PyGetActuators() } const char SCA_PythonController::GetSensor_doc[] = -"GetSensor (char sensorname) return linked sensor that is named [sensorname]\n"; +"getSensor (char sensorname) return linked sensor that is named [sensorname]\n"; PyObject* SCA_PythonController::PyGetSensor(PyObject* value) { char *scriptArg = PyString_AsString(value); if (scriptArg==NULL) { - PyErr_SetString(PyExc_TypeError, "expected a string (sensor name)"); + PyErr_SetString(PyExc_TypeError, "controller.getSensor(string): Python Controller, expected a string (sensor name)"); return NULL; } @@ -438,21 +438,21 @@ SCA_PythonController::PyGetSensor(PyObject* value) } } - PyErr_Format(PyExc_AttributeError, "Unable to find requested sensor \"%s\"", scriptArg); + PyErr_Format(PyExc_AttributeError, "controller.getSensor(string): Python Controller, unable to find requested sensor \"%s\"", scriptArg); return NULL; } const char SCA_PythonController::GetActuator_doc[] = -"GetActuator (char sensorname) return linked actuator that is named [actuatorname]\n"; +"getActuator (char sensorname) return linked actuator that is named [actuatorname]\n"; PyObject* SCA_PythonController::PyGetActuator(PyObject* value) { char *scriptArg = PyString_AsString(value); if (scriptArg==NULL) { - PyErr_SetString(PyExc_TypeError, "expected a string (actuator name)"); + PyErr_SetString(PyExc_TypeError, "controller.getActuator(string): Python Controller, expected a string (actuator name)"); return NULL; } @@ -465,7 +465,7 @@ SCA_PythonController::PyGetActuator(PyObject* value) } } - PyErr_Format(PyExc_AttributeError, "Unable to find requested actuator \"%s\"", scriptArg); + PyErr_Format(PyExc_AttributeError, "controller.getActuator(string): Python Controller, unable to find requested actuator \"%s\"", scriptArg); return NULL; } @@ -536,7 +536,7 @@ int SCA_PythonController::pyattr_set_script(void *self_v, const KX_PYATTRIBUTE_D char *scriptArg = PyString_AsString(value); if (scriptArg==NULL) { - PyErr_SetString(PyExc_TypeError, "expected a string (script name)"); + PyErr_SetString(PyExc_TypeError, "controller.script = string: Python Controller, expected a string script text"); return -1; } diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp index 6fb10faaf8c..3a72d9b7652 100644 --- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp +++ b/source/gameengine/GameLogic/SCA_RandomActuator.cpp @@ -386,7 +386,7 @@ int SCA_RandomActuator::pyattr_set_seed(void *self, const struct KX_PYATTRIBUTE_ act->m_base->SetSeed(ival); return 0; } else { - PyErr_SetString(PyExc_TypeError, "expected an integer"); + PyErr_SetString(PyExc_TypeError, "actuator.seed = int: Random Actuator, expected an integer"); return 1; } } diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.cpp b/source/gameengine/GameLogic/SCA_RandomSensor.cpp index e04d2a8ab90..5ead82db428 100644 --- a/source/gameengine/GameLogic/SCA_RandomSensor.cpp +++ b/source/gameengine/GameLogic/SCA_RandomSensor.cpp @@ -224,7 +224,7 @@ int SCA_RandomSensor::pyattr_set_seed(void *self_v, const KX_PYATTRIBUTE_DEF *at { SCA_RandomSensor* self= static_cast<SCA_RandomSensor*>(self_v); if (!PyInt_Check(value)) { - PyErr_SetString(PyExc_TypeError, "expected an integer"); + PyErr_SetString(PyExc_TypeError, "sensor.seed = int: Random Sensor, expected an integer"); return -1; } self->m_basegenerator->SetSeed(PyInt_AsLong(value)); |