1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Allow the server to control fog_distance and fog_start via the sky-api (#13448)

This commit is contained in:
lhofhansl 2023-06-30 19:11:17 -07:00 committed by GitHub
parent dde8f0e20a
commit 0ade097e99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 80 additions and 21 deletions

View file

@ -1803,6 +1803,11 @@ int ObjectRef::l_set_sky(lua_State *L)
// pop "sky_color" table
lua_pop(L, 1);
}
lua_getfield(L, 2, "fog");
if (lua_istable(L, -1)) {
sky_params.fog_distance = getintfield_default(L, -1, "fog_distance", sky_params.fog_distance);
sky_params.fog_start = getfloatfield_default(L, -1, "fog_start", sky_params.fog_start);
}
} else {
// Handle old set_sky calls, and log deprecated:
log_deprecated(L, "Deprecated call to set_sky, please check lua_api.md");
@ -1923,7 +1928,6 @@ int ObjectRef::l_get_sky(lua_State *L)
lua_pushnumber(L, skybox_params.body_orbit_tilt);
lua_setfield(L, -2, "body_orbit_tilt");
}
lua_newtable(L);
s16 i = 1;
for (const std::string &texture : skybox_params.textures) {
@ -1936,6 +1940,14 @@ int ObjectRef::l_get_sky(lua_State *L)
push_sky_color(L, skybox_params);
lua_setfield(L, -2, "sky_color");
lua_newtable(L); // fog
lua_pushinteger(L, skybox_params.fog_distance >= 0 ? skybox_params.fog_distance : -1);
lua_setfield(L, -2, "fog_distance");
lua_pushnumber(L, skybox_params.fog_start >= 0 ? skybox_params.fog_start : -1.0f);
lua_setfield(L, -2, "fog_start");
lua_setfield(L, -2, "fog");
return 1;
}