From b60d38b7f9629e9df5f8c6c840f0e985912c1531 Mon Sep 17 00:00:00 2001 From: Zughy <63455151+Zughy@users.noreply.github.com> Date: Fri, 26 May 2023 13:45:42 +0200 Subject: [PATCH] Reset day/night ratio even when passing no arguments (#13524) * reset day_night_ratio when passing zero fields * Update lua_api.md --------- Co-authored-by: Zughy <4279489-marco_a@users.noreply.gitlab.com> --- doc/lua_api.md | 2 +- src/script/lua_api/l_object.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/lua_api.md b/doc/lua_api.md index c596da2ab..c22b7a3c0 100644 --- a/doc/lua_api.md +++ b/doc/lua_api.md @@ -7657,7 +7657,7 @@ child will follow movement and rotation of that bone. * `override_day_night_ratio(ratio or nil)` * `0`...`1`: Overrides day-night ratio, controlling sunlight to a specific amount. - * `nil`: Disables override, defaulting to sunlight based on day-night cycle + * Passing no arguments disables override, defaulting to sunlight based on day-night cycle * `get_day_night_ratio()`: returns the ratio or nil if it isn't overridden * `set_local_animation(idle, walk, dig, walk_while_dig, frame_speed)`: set animation for player model in third person view. diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index 01b1ddeaa..6b31d2541 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -2207,7 +2207,7 @@ int ObjectRef::l_override_day_night_ratio(lua_State *L) bool do_override = false; float ratio = 0.0f; - if (!lua_isnil(L, 2)) { + if (!lua_isnoneornil(L, 2)) { do_override = true; ratio = readParam(L, 2); luaL_argcheck(L, ratio >= 0.0f && ratio <= 1.0f, 1,