From: sapier Date: Sat, 4 May 2013 23:44:55 +0000 (+0200) Subject: Allow nil as puncher e.g. to do damage by tnt X-Git-Tag: 0.4.7~14^2~22 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=55a97f4605a263f4b670b447cd4af9ffa1a8d472;p=oweals%2Fminetest.git Allow nil as puncher e.g. to do damage by tnt --- diff --git a/src/content_sao.cpp b/src/content_sao.cpp index 24a9186f7..47b94a5d9 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;