Merge latest changes from branch lua-changes.
--- a/Aquaria/Entity.h Thu Jan 06 01:33:47 2011 +0900
+++ b/Aquaria/Entity.h Thu Jan 06 01:43:28 2011 +0900
@@ -271,6 +271,7 @@
bool canSetState(int state);
virtual void message(const std::string &msg, int v);
+ virtual void message(const std::string &msg, void *v) {}
bool isUnderWater(const Vector &o=Vector());
//virtual void onHitBySpell(Spell *spell) {}
--- a/Aquaria/ScriptInterface.cpp Thu Jan 06 01:33:47 2011 +0900
+++ b/Aquaria/ScriptInterface.cpp Thu Jan 06 01:43:28 2011 +0900
@@ -3569,7 +3569,10 @@
Entity *e = entity(L);
if (e)
{
- e->message(getString(L, 2), lua_tonumber(L, 3));
+ if (lua_isuserdata(L, 3))
+ e->message(getString(L, 2), lua_touserdata(L, 3));
+ else
+ e->message(getString(L, 2), lua_tonumber(L, 3));
}
luaReturnNum(0);
}
@@ -9154,6 +9157,15 @@
return doCall(3);
}
+bool Script::call(const char *name, void *param1, const char *param2, void *param3)
+{
+ lookupFunc(name);
+ luaPushPointer(L, param1);
+ lua_pushstring(L, param2);
+ luaPushPointer(L, param3);
+ return doCall(3);
+}
+
bool Script::call(const char *name, void *param1, void *param2, void *param3)
{
lookupFunc(name);
--- a/Aquaria/ScriptInterface.h Thu Jan 06 01:33:47 2011 +0900
+++ b/Aquaria/ScriptInterface.h Thu Jan 06 01:43:28 2011 +0900
@@ -49,6 +49,8 @@
bool call(const char *name, void *param1, float param2, float param3, bool *ret1);
// function(pointer, string, number)
bool call(const char *name, void *param1, const char *param2, float param3);
+ // function(pointer, string, pointer)
+ bool call(const char *name, void *param1, const char *param2, void *param3);
// function(pointer, pointer, pointer)
bool call(const char *name, void *param1, void *param2, void *param3);
// function(pointer, number, number, number)
--- a/Aquaria/ScriptedEntity.cpp Thu Jan 06 01:33:47 2011 +0900
+++ b/Aquaria/ScriptedEntity.cpp Thu Jan 06 01:43:28 2011 +0900
@@ -102,6 +102,16 @@
Entity::message(msg, v);
}
+void ScriptedEntity::message(const std::string &msg, void *v)
+{
+ if (script)
+ {
+ if (!script->call("msg", this, msg.c_str(), v))
+ luaDebugMsg("msg", script->getLastError());
+ }
+ Entity::message(msg, v);
+}
+
void ScriptedEntity::warpSegments()
{
Segmented::warpSegments(position);
--- a/Aquaria/ScriptedEntity.h Thu Jan 06 01:33:47 2011 +0900
+++ b/Aquaria/ScriptedEntity.h Thu Jan 06 01:43:28 2011 +0900
@@ -48,6 +48,7 @@
void lightFlare();
void entityDied(Entity *e);
void message(const std::string &msg, int v);
+ void message(const std::string &msg, void *v);
static bool runningActivation;