Undo revision 23130 which was a merge with 2.5, a messy one because I did something...
[blender.git] / source / gameengine / GameLogic / SCA_ActuatorSensor.cpp
index 428362a..11ea089 100644 (file)
@@ -143,6 +143,10 @@ PyTypeObject SCA_ActuatorSensor::Type = {
 };
 
 PyMethodDef SCA_ActuatorSensor::Methods[] = {
+       //Deprecated functions ------>
+       {"getActuator", (PyCFunction) SCA_ActuatorSensor::sPyGetActuator, METH_NOARGS, (const char *)GetActuator_doc},
+       {"setActuator", (PyCFunction) SCA_ActuatorSensor::sPySetActuator, METH_VARARGS, (const char *)SetActuator_doc},
+       //<----- Deprecated
        {NULL,NULL} //Sentinel
 };
 
@@ -163,4 +167,41 @@ int SCA_ActuatorSensor::CheckActuator(void *self, const PyAttributeDef*)
        return 1;
 }
 
+/* 3. getActuator */
+const char SCA_ActuatorSensor::GetActuator_doc[] = 
+"getActuator()\n"
+"\tReturn the Actuator with which the sensor operates.\n";
+PyObject* SCA_ActuatorSensor::PyGetActuator() 
+{
+       ShowDeprecationWarning("getActuator()", "the actuator property");
+       return PyUnicode_FromString(m_checkactname);
+}
+
+/* 4. setActuator */
+const char SCA_ActuatorSensor::SetActuator_doc[] = 
+"setActuator(name)\n"
+"\t- name: string\n"
+"\tSets the Actuator with which to operate. If there is no Actuator\n"
+"\tof this name, the call is ignored.\n";
+PyObject* SCA_ActuatorSensor::PySetActuator(PyObject* args) 
+{
+       ShowDeprecationWarning("setActuator()", "the actuator property");
+       /* We should query whether the name exists. Or should we create a prop   */
+       /* on the fly?                                                           */
+       char *actNameArg = NULL;
+
+       if (!PyArg_ParseTuple(args, "s:setActuator", &actNameArg)) {
+               return NULL;
+       }
+
+       SCA_IActuator* act = GetParent()->FindActuator(STR_String(actNameArg));
+       if (act) {
+               m_checkactname = actNameArg;
+               m_actuator = act;
+       } else {
+               ; /* error: bad actuator name */
+       }
+       Py_RETURN_NONE;
+}
+
 /* eof */