summaryrefslogtreecommitdiff
path: root/src/script/common/helper.h
diff options
context:
space:
mode:
authorZughy <63455151+Zughy@users.noreply.github.com>2020-11-04 21:43:18 +0100
committerGitHub <noreply@github.com>2020-11-04 21:43:18 +0100
commit72b93ec0d75e97ec343e5b936b858d686580677d (patch)
treef02050352671a695a3eac30a0cc24be0bdd02584 /src/script/common/helper.h
parent39213bd00a8d00861616d94a29823cb2214f742e (diff)
downloadminetest-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.h5
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);
+ }
};