diff options
author | sfan5 <sfan5@live.de> | 2021-01-30 12:41:27 +0100 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2021-01-31 20:38:12 +0100 |
commit | a01a02f7a1ec915c207632085cd5f24eab28da17 (patch) | |
tree | fd4eb76bf161237cf59e389821a6865ec0c74ef0 /src/script/lua_api | |
parent | fd1c1a755eaa2251c99680df3c72ca8886ca0a4e (diff) | |
download | minetest-a01a02f7a1ec915c207632085cd5f24eab28da17.tar.gz minetest-a01a02f7a1ec915c207632085cd5f24eab28da17.tar.bz2 minetest-a01a02f7a1ec915c207632085cd5f24eab28da17.zip |
Preserve immortal group for players when damage is disabled
Diffstat (limited to 'src/script/lua_api')
-rw-r--r-- | src/script/lua_api/l_object.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index ba201a9d3..07aa3f7c9 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -355,6 +355,15 @@ int ObjectRef::l_set_armor_groups(lua_State *L) ItemGroupList groups; read_groups(L, 2, groups); + if (sao->getType() == ACTIVEOBJECT_TYPE_PLAYER) { + if (!g_settings->getBool("enable_damage") && !itemgroup_get(groups, "immortal")) { + warningstream << "Mod tried to enable damage for a player, but it's " + "disabled globally. Ignoring." << std::endl; + infostream << script_get_backtrace(L) << std::endl; + groups["immortal"] = 1; + } + } + sao->setArmorGroups(groups); return 0; } |