Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Bolsee <benoit.bolsee@online.be>2009-01-03 01:09:57 +0300
committerBenoit Bolsee <benoit.bolsee@online.be>2009-01-03 01:09:57 +0300
commit10702bf93f14441066ceba3204f932a5ba099c2e (patch)
tree0a7e9b1190eb317c5bf655acab6d15821693c5e6 /source/gameengine/GameLogic/SCA_RandomSensor.cpp
parentcc569504d0468ec19a1018ea804aa418c134cb0f (diff)
BGE API cleanup: more bricks converted to attributes.
Diffstat (limited to 'source/gameengine/GameLogic/SCA_RandomSensor.cpp')
-rw-r--r--source/gameengine/GameLogic/SCA_RandomSensor.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.cpp b/source/gameengine/GameLogic/SCA_RandomSensor.cpp
index 202fd6382e6..8fae0bbeaba 100644
--- a/source/gameengine/GameLogic/SCA_RandomSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_RandomSensor.cpp
@@ -160,10 +160,39 @@ PyMethodDef SCA_RandomSensor::Methods[] = {
{NULL,NULL} //Sentinel
};
+PyAttributeDef SCA_RandomSensor::Attributes[] = {
+ KX_PYATTRIBUTE_BOOL_RO("lastDraw",SCA_RandomSensor,m_lastdraw),
+ {NULL} //Sentinel
+};
+
PyObject* SCA_RandomSensor::_getattr(const STR_String& attr) {
+ PyObject* object = _getattr_self(Attributes, this, attr);
+ if (object != NULL)
+ return object;
+ if (attr == "seed") {
+ return PyInt_FromLong(m_basegenerator->GetSeed());
+ }
_getattr_up(SCA_ISensor);
}
+int SCA_RandomSensor::_setattr(const STR_String& attr, PyObject *value)
+{
+ int ret = _setattr_self(Attributes, this, attr, value);
+ if (ret >= 0)
+ return ret;
+ if (attr == "seed") {
+ if (PyInt_Check(value)) {
+ int ival = PyInt_AsLong(value);
+ m_basegenerator->SetSeed(ival);
+ return 0;
+ } else {
+ PyErr_SetString(PyExc_TypeError, "expected an integer");
+ return 1;
+ }
+ }
+ return SCA_ISensor::_setattr(attr, value);
+}
+
/* 1. setSeed */
const char SCA_RandomSensor::SetSeed_doc[] =
"setSeed(seed)\n"
@@ -172,6 +201,7 @@ const char SCA_RandomSensor::SetSeed_doc[] =
"\tequal series. If the seed is 0, the generator will produce\n"
"\tthe same value on every call.\n";
PyObject* SCA_RandomSensor::PySetSeed(PyObject* self, PyObject* args, PyObject* kwds) {
+ ShowDeprecationWarning("setSeed()", "the seed property");
long seedArg;
if(!PyArg_ParseTuple(args, "i", &seedArg)) {
return NULL;
@@ -188,6 +218,7 @@ const char SCA_RandomSensor::GetSeed_doc[] =
"\tReturns the initial seed of the generator. Equal seeds produce\n"
"\tequal series.\n";
PyObject* SCA_RandomSensor::PyGetSeed(PyObject* self, PyObject* args, PyObject* kwds) {
+ ShowDeprecationWarning("getSeed()", "the seed property");
return PyInt_FromLong(m_basegenerator->GetSeed());
}
@@ -196,6 +227,7 @@ const char SCA_RandomSensor::GetLastDraw_doc[] =
"getLastDraw()\n"
"\tReturn the last value that was drawn.\n";
PyObject* SCA_RandomSensor::PyGetLastDraw(PyObject* self, PyObject* args, PyObject* kwds) {
+ ShowDeprecationWarning("getLastDraw()", "the lastDraw property");
return PyInt_FromLong(m_lastdraw);
}