diff options
author | Zughy <63455151+Zughy@users.noreply.github.com> | 2020-11-04 21:43:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-04 21:43:18 +0100 |
commit | 72b93ec0d75e97ec343e5b936b858d686580677d (patch) | |
tree | f02050352671a695a3eac30a0cc24be0bdd02584 /src/script/common/helper.h | |
parent | 39213bd00a8d00861616d94a29823cb2214f742e (diff) | |
download | minetest-72b93ec0d75e97ec343e5b936b858d686580677d.tar.gz minetest-72b93ec0d75e97ec343e5b936b858d686580677d.tar.bz2 minetest-72b93ec0d75e97ec343e5b936b858d686580677d.zip |
Fix ObjectRef errors due to lua_isnil() (#10564)
Treat 'none' values as 'nil'
Diffstat (limited to 'src/script/common/helper.h')
-rw-r--r-- | src/script/common/helper.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/script/common/helper.h b/src/script/common/helper.h index d639d6e16..7a794dc9b 100644 --- a/src/script/common/helper.h +++ b/src/script/common/helper.h @@ -50,5 +50,8 @@ protected: * @return read value from Lua or default value if nil */ template <typename T> - static T readParam(lua_State *L, int index, const T &default_value); + static inline T readParam(lua_State *L, int index, const T &default_value) + { + return lua_isnoneornil(L, index) ? default_value : readParam<T>(L, index); + } }; |