diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2021-02-10 19:50:36 +0100 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2021-02-10 19:50:36 +0100 |
commit | 1fbbb768252f872dfa961d3a73460d996164d527 (patch) | |
tree | e9faf93dbd894b253ac3d1f0895b7468e8fee50d /src/script/lua_api/l_object.cpp | |
parent | 74f5f033e04c0d8694815fedb795838d4926cbc9 (diff) | |
parent | 9736b9cea5f841bb0e9bb2c9c05c3b2560327064 (diff) | |
download | dragonfireclient-1fbbb768252f872dfa961d3a73460d996164d527.tar.xz |
Merge branch 'master' of https://github.com/minetest/minetest
Diffstat (limited to 'src/script/lua_api/l_object.cpp')
-rw-r--r-- | src/script/lua_api/l_object.cpp | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index f52e4892e..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; } @@ -399,7 +408,7 @@ int ObjectRef::l_get_animation(lua_State *L) if (sao == nullptr) return 0; - v2f frames = v2f(1,1); + v2f frames = v2f(1, 1); float frame_speed = 15; float frame_blend = 0; bool frame_loop = true; @@ -463,8 +472,8 @@ int ObjectRef::l_set_eye_offset(lua_State *L) if (player == nullptr) return 0; - v3f offset_first = read_v3f(L, 2); - v3f offset_third = read_v3f(L, 3); + v3f offset_first = readParam<v3f>(L, 2, v3f(0, 0, 0)); + v3f offset_third = readParam<v3f>(L, 3, v3f(0, 0, 0)); // Prevent abuse of offset values (keep player always visible) offset_third.X = rangelim(offset_third.X,-10,10); @@ -537,9 +546,9 @@ int ObjectRef::l_set_bone_position(lua_State *L) if (sao == nullptr) return 0; - std::string bone = readParam<std::string>(L, 2); - v3f position = check_v3f(L, 3); - v3f rotation = check_v3f(L, 4); + std::string bone = readParam<std::string>(L, 2, ""); + v3f position = readParam<v3f>(L, 3, v3f(0, 0, 0)); + v3f rotation = readParam<v3f>(L, 4, v3f(0, 0, 0)); sao->setBonePosition(bone, position, rotation); return 0; @@ -554,7 +563,7 @@ int ObjectRef::l_get_bone_position(lua_State *L) if (sao == nullptr) return 0; - std::string bone = readParam<std::string>(L, 2); + std::string bone = readParam<std::string>(L, 2, ""); v3f position = v3f(0, 0, 0); v3f rotation = v3f(0, 0, 0); @@ -578,10 +587,10 @@ int ObjectRef::l_set_attach(lua_State *L) if (sao == parent) throw LuaError("ObjectRef::set_attach: attaching object to itself is not allowed."); - int parent_id = 0; + int parent_id; std::string bone; - v3f position = v3f(0, 0, 0); - v3f rotation = v3f(0, 0, 0); + v3f position; + v3f rotation; bool force_visible; sao->getAttachment(&parent_id, &bone, &position, &rotation, &force_visible); @@ -590,9 +599,9 @@ int ObjectRef::l_set_attach(lua_State *L) old_parent->removeAttachmentChild(sao->getId()); } - bone = readParam<std::string>(L, 3, ""); - position = read_v3f(L, 4); - rotation = read_v3f(L, 5); + bone = readParam<std::string>(L, 3, ""); + position = readParam<v3f>(L, 4, v3f(0, 0, 0)); + rotation = readParam<v3f>(L, 5, v3f(0, 0, 0)); force_visible = readParam<bool>(L, 6, false); sao->setAttachment(parent->getId(), bone, position, rotation, force_visible); @@ -609,10 +618,10 @@ int ObjectRef::l_get_attach(lua_State *L) if (sao == nullptr) return 0; - int parent_id = 0; + int parent_id; std::string bone; - v3f position = v3f(0, 0, 0); - v3f rotation = v3f(0, 0, 0); + v3f position; + v3f rotation; bool force_visible; sao->getAttachment(&parent_id, &bone, &position, &rotation, &force_visible); @@ -892,9 +901,6 @@ int ObjectRef::l_set_yaw(lua_State *L) if (entitysao == nullptr) return 0; - if (isNaN(L, 2)) - throw LuaError("ObjectRef::set_yaw: NaN value is not allowed."); - float yaw = readParam<float>(L, 2) * core::RADTODEG; entitysao->setRotation(v3f(0, yaw, 0)); @@ -2199,7 +2205,7 @@ int ObjectRef::l_set_minimap_modes(lua_State *L) luaL_checktype(L, 2, LUA_TTABLE); std::vector<MinimapMode> modes; - s16 selected_mode = luaL_checkint(L, 3); + s16 selected_mode = readParam<s16>(L, 3); lua_pushnil(L); while (lua_next(L, 2) != 0) { |