diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-12-02 11:51:41 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-12-02 11:51:41 +0200 |
commit | e8b0722137b47b9b17cef94a9a9f0f52d03f4ea8 (patch) | |
tree | 6dee9b82a6569104630056d902e77cca5fbda2a4 /src | |
parent | ed128fff263432f46cfbbc90657682b3c2c17132 (diff) | |
download | minetest-e8b0722137b47b9b17cef94a9a9f0f52d03f4ea8.tar.gz minetest-e8b0722137b47b9b17cef94a9a9f0f52d03f4ea8.tar.bz2 minetest-e8b0722137b47b9b17cef94a9a9f0f52d03f4ea8.zip |
Add time_from_last_punch to Lua API
Diffstat (limited to 'src')
-rw-r--r-- | src/content_sao.cpp | 2 | ||||
-rw-r--r-- | src/scriptapi.cpp | 7 | ||||
-rw-r--r-- | src/scriptapi.h | 2 |
3 files changed, 6 insertions, 5 deletions
diff --git a/src/content_sao.cpp b/src/content_sao.cpp index e0f230bbc..171e315af 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -1678,7 +1678,7 @@ void LuaEntitySAO::punch(ServerActiveObject *puncher, float time_from_last_punch if(!m_registered) return; lua_State *L = m_env->getLua(); - scriptapi_luaentity_punch(L, m_id, puncher); + scriptapi_luaentity_punch(L, m_id, puncher, time_from_last_punch); } void LuaEntitySAO::rightClick(ServerActiveObject *clicker) diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp index 951ff6f83..dce454ea4 100644 --- a/src/scriptapi.cpp +++ b/src/scriptapi.cpp @@ -3208,9 +3208,9 @@ void scriptapi_luaentity_step(lua_State *L, u16 id, float dtime) script_error(L, "error running function 'on_step': %s\n", lua_tostring(L, -1)); } -// Calls entity:on_punch(ObjectRef puncher) +// Calls entity:on_punch(ObjectRef puncher, time_from_last_punch) void scriptapi_luaentity_punch(lua_State *L, u16 id, - ServerActiveObject *puncher) + ServerActiveObject *puncher, float time_from_last_punch) { realitycheck(L); assert(lua_checkstack(L, 20)); @@ -3228,8 +3228,9 @@ void scriptapi_luaentity_punch(lua_State *L, u16 id, luaL_checktype(L, -1, LUA_TFUNCTION); lua_pushvalue(L, object); // self objectref_get_or_create(L, puncher); // Clicker reference + lua_pushnumber(L, time_from_last_punch); // Call with 2 arguments, 0 results - if(lua_pcall(L, 2, 0, 0)) + if(lua_pcall(L, 3, 0, 0)) script_error(L, "error running function 'on_punch': %s\n", lua_tostring(L, -1)); } diff --git a/src/scriptapi.h b/src/scriptapi.h index fe9329d75..2baf6f836 100644 --- a/src/scriptapi.h +++ b/src/scriptapi.h @@ -83,7 +83,7 @@ void scriptapi_luaentity_get_properties(lua_State *L, u16 id, LuaEntityProperties *prop); void scriptapi_luaentity_step(lua_State *L, u16 id, float dtime); void scriptapi_luaentity_punch(lua_State *L, u16 id, - ServerActiveObject *puncher); + ServerActiveObject *puncher, float time_from_last_punch); void scriptapi_luaentity_rightclick(lua_State *L, u16 id, ServerActiveObject *clicker); |