]> git.lizzy.rs Git - minetest.git/blobdiff - src/script/lua_api/l_object.cpp
Lua API: Document shader dependencies of set_lighting() (#13079)
[minetest.git] / src / script / lua_api / l_object.cpp
index b63585a31814e98d88d336a922b9f5af286cebf7..0a3e05907bb60e7e46e978f3d33c3e137d81a2e3 100644 (file)
@@ -721,8 +721,7 @@ int ObjectRef::l_set_nametag_attributes(lua_State *L)
        }
        lua_pop(L, 1);
 
-       std::string nametag = getstringfield_default(L, 2, "text", "");
-       prop->nametag = nametag;
+       prop->nametag = getstringfield_default(L, 2, "text", prop->nametag);
 
        prop->validate();
        sao->notifyObjectPropertiesModified();
@@ -2295,9 +2294,10 @@ int ObjectRef::l_set_lighting(lua_State *L)
        Lighting lighting = player->getLighting();
        lua_getfield(L, 2, "shadows");
        if (lua_istable(L, -1)) {
-               lighting.shadow_intensity = getfloatfield_default(L, -1, "intensity",    lighting.shadow_intensity);
+               getfloatfield(L, -1, "intensity", lighting.shadow_intensity);
        }
-       lua_pop(L, -1);
+       lua_pop(L, 1); // shadows
+       getfloatfield(L, -1, "saturation", lighting.saturation);
 
        getServer(L)->setLighting(player, lighting);
        return 0;
@@ -2319,6 +2319,8 @@ int ObjectRef::l_get_lighting(lua_State *L)
        lua_pushnumber(L, lighting.shadow_intensity);
        lua_setfield(L, -2, "intensity");
        lua_setfield(L, -2, "shadows");
+       lua_pushnumber(L, lighting.saturation);
+       lua_setfield(L, -2, "saturation");
        return 1;
 }