summaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorPaul Ouellette <oue.paul18@gmail.com>2019-04-11 15:45:39 -0400
committerrubenwardy <rw@rubenwardy.com>2019-04-11 20:45:39 +0100
commit22ad820aa459e055fde817d94f31a9461aac2726 (patch)
tree8df2ea572c26ecf3f4e0c37208c5556281a47221 /src/script
parent1e5f2e0f133af42764dcd9386ccd59f4bf948328 (diff)
downloadminetest-22ad820aa459e055fde817d94f31a9461aac2726.tar.gz
minetest-22ad820aa459e055fde817d94f31a9461aac2726.tar.bz2
minetest-22ad820aa459e055fde817d94f31a9461aac2726.zip
Add node field to PlayerHPChangeReason table (#8368)
Diffstat (limited to 'src/script')
-rw-r--r--src/script/cpp_api/s_base.cpp4
-rw-r--r--src/script/lua_api/l_object.cpp7
2 files changed, 8 insertions, 3 deletions
diff --git a/src/script/cpp_api/s_base.cpp b/src/script/cpp_api/s_base.cpp
index a8ed902dd..e73f613ce 100644
--- a/src/script/cpp_api/s_base.cpp
+++ b/src/script/cpp_api/s_base.cpp
@@ -404,6 +404,10 @@ void ScriptApiBase::pushPlayerHPChangeReason(lua_State *L, const PlayerHPChangeR
objectrefGetOrCreate(L, reason.object);
lua_setfield(L, -2, "object");
}
+ if (!reason.node.empty()) {
+ lua_pushstring(L, reason.node.c_str());
+ lua_setfield(L, -2, "node");
+ }
}
Server* ScriptApiBase::getServer()
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp
index 597cb84a8..2efcd894a 100644
--- a/src/script/lua_api/l_object.cpp
+++ b/src/script/lua_api/l_object.cpp
@@ -170,8 +170,8 @@ int ObjectRef::l_punch(lua_State *L)
ObjectRef *puncher_ref = checkobject(L, 2);
ServerActiveObject *co = getobject(ref);
ServerActiveObject *puncher = getobject(puncher_ref);
- if (co == NULL) return 0;
- if (puncher == NULL) return 0;
+ if (!co || !puncher)
+ return 0;
v3f dir;
if (lua_type(L, 5) != LUA_TTABLE)
dir = co->getBasePosition() - puncher->getBasePosition();
@@ -192,7 +192,8 @@ int ObjectRef::l_punch(lua_State *L)
// If the punched is a player, and its HP changed
if (src_original_hp != co->getHP() &&
co->getType() == ACTIVEOBJECT_TYPE_PLAYER) {
- getServer(L)->SendPlayerHPOrDie((PlayerSAO *)co, PlayerHPChangeReason(PlayerHPChangeReason::PLAYER_PUNCH, puncher));
+ getServer(L)->SendPlayerHPOrDie((PlayerSAO *)co,
+ PlayerHPChangeReason(PlayerHPChangeReason::PLAYER_PUNCH, puncher));
}
// If the puncher is a player, and its HP changed