diff options
author | Perttu Ahola <celeron55@gmail.com> | 2012-03-10 01:38:48 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-03-10 11:28:14 +0200 |
commit | f9da2c9507f10a9193c9bd94d69cc85e53b58ba2 (patch) | |
tree | 00885e82f4ab7ff193d481637bbfdeb80c41d0a6 /src/scriptapi.cpp | |
parent | 989aba1966373885d4cac306daea25e102f8d68d (diff) | |
download | minetest-f9da2c9507f10a9193c9bd94d69cc85e53b58ba2.tar.gz minetest-f9da2c9507f10a9193c9bd94d69cc85e53b58ba2.tar.bz2 minetest-f9da2c9507f10a9193c9bd94d69cc85e53b58ba2.zip |
Immediate smoke puff when a normal entity is punched to death
Diffstat (limited to 'src/scriptapi.cpp')
-rw-r--r-- | src/scriptapi.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp index 541baa61c..7bdf7a9f4 100644 --- a/src/scriptapi.cpp +++ b/src/scriptapi.cpp @@ -4226,8 +4226,7 @@ void scriptapi_environment_on_generated(lua_State *L, v3s16 minp, v3s16 maxp) luaentity */ -bool scriptapi_luaentity_add(lua_State *L, u16 id, const char *name, - const std::string &staticdata) +bool scriptapi_luaentity_add(lua_State *L, u16 id, const char *name) { realitycheck(L); assert(lua_checkstack(L, 20)); @@ -4274,6 +4273,21 @@ bool scriptapi_luaentity_add(lua_State *L, u16 id, const char *name, lua_pushvalue(L, object); // Copy object to top of stack lua_settable(L, -3); + return true; +} + +void scriptapi_luaentity_activate(lua_State *L, u16 id, + const std::string &staticdata) +{ + realitycheck(L); + assert(lua_checkstack(L, 20)); + infostream<<"scriptapi_luaentity_activate: id="<<id<<std::endl; + StackUnroller stack_unroller(L); + + // Get minetest.luaentities[id] + luaentity_get(L, id); + int object = lua_gettop(L); + // Get on_activate function lua_pushvalue(L, object); lua_getfield(L, -1, "on_activate"); @@ -4283,11 +4297,9 @@ bool scriptapi_luaentity_add(lua_State *L, u16 id, const char *name, lua_pushlstring(L, staticdata.c_str(), staticdata.size()); // Call with 2 arguments, 0 results if(lua_pcall(L, 2, 0, 0)) - script_error(L, "error running function %s:on_activate: %s\n", - name, lua_tostring(L, -1)); + script_error(L, "error running function on_activate: %s\n", + lua_tostring(L, -1)); } - - return true; } void scriptapi_luaentity_rm(lua_State *L, u16 id) |