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-04-08 20:57:08 +0400
committerBenoit Bolsee <benoit.bolsee@online.be>2009-04-08 20:57:08 +0400
commitdb33320df7f4db6480a15502baecaafefc1be63d (patch)
tree532ffe8782fec1909a8725b2eb0fe559af8ec704 /source/gameengine/Ketsji/KX_GameObject.cpp
parent370850146f5ab1af11ec3a28abd1bad2f60314a4 (diff)
BGE patch #18350: Add sendMessage() to GameLogic. Added sendMessage to both GameLogic and KX_GameObject.
Diffstat (limited to 'source/gameengine/Ketsji/KX_GameObject.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index ea53ffea48f..5085b52adda 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -66,6 +66,7 @@ typedef unsigned long uint_ptr;
#include "SCA_IActuator.h"
#include "SCA_ISensor.h"
#include "SCA_IController.h"
+#include "NG_NetworkScene.h" //Needed for sendMessage()
#include "PyObjectPlus.h" /* python stuff */
@@ -1039,7 +1040,8 @@ PyMethodDef KX_GameObject::Methods[] = {
KX_PYMETHODTABLE(KX_GameObject, rayCast),
KX_PYMETHODTABLE_O(KX_GameObject, getDistanceTo),
KX_PYMETHODTABLE_O(KX_GameObject, getVectTo),
-
+ KX_PYMETHODTABLE(KX_GameObject, sendMessage),
+
// deprecated
{"getPosition", (PyCFunction) KX_GameObject::sPyGetPosition, METH_NOARGS},
{"setPosition", (PyCFunction) KX_GameObject::sPySetPosition, METH_O},
@@ -2335,6 +2337,26 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast,
return Py_BuildValue("OOO", Py_None, Py_None, Py_None);
}
+KX_PYMETHODDEF_DOC_VARARGS(KX_GameObject, sendMessage,
+ "sendMessage(subject, [body, to])\n"
+"sends a message in same manner as a message actuator"
+"subject = Subject of the message (string)"
+"body = Message body (string)"
+"to = Name of object to send the message to")
+{
+ char* subject;
+ char* body = "";
+ char* to = "";
+ const STR_String& from = GetName();
+
+ if (!PyArg_ParseTuple(args, "s|sss", &subject, &body, &to))
+ return NULL;
+
+ KX_GetActiveScene()->GetNetworkScene()->SendMessage(to, from, subject, body);
+
+ Py_RETURN_NONE;
+}
+
/* ---------------------------------------------------------------------
* Some stuff taken from the header
* --------------------------------------------------------------------- */