From 55a97f4605a263f4b670b447cd4af9ffa1a8d472 Mon Sep 17 00:00:00 2001 From: sapier Date: Sun, 5 May 2013 01:44:55 +0200 Subject: [PATCH] Allow nil as puncher e.g. to do damage by tnt --- src/content_sao.cpp | 15 +++++++++++++-- src/scriptapi_object.cpp | 23 ++++++++++++++++------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/content_sao.cpp b/src/content_sao.cpp index 24a9186f..47b94a5d 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -673,8 +673,14 @@ int LuaEntitySAO::punch(v3f dir, { setHP(getHP() - result.damage); + + std::string punchername = "nil"; + + if ( puncher != 0 ) + punchername = puncher->getDescription(); + actionstream<getDescription()<<", damage "<getDescription(); + actionstream<<"Player "<getName()<<" punched by " - <getDescription()<<", damage "<getBasePosition() - puncher->getBasePosition(); - else - dir = read_v3f(L, 5); + } + float time_from_last_punch = 1000000; if(lua_isnumber(L, 3)) time_from_last_punch = lua_tonumber(L, 3); + ToolCapabilities toolcap = read_tool_capabilities(L, 4); + + if(lua_type(L, 5) == LUA_TTABLE) + dir = read_v3f(L, 5); dir.normalize(); + // Do it co->punch(dir, &toolcap, puncher, time_from_last_punch); return 0; -- 2.30.2