aboutsummaryrefslogtreecommitdiff
path: root/src/script/common/helper.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/common/helper.h')
-rw-r--r--src/script/common/helper.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/script/common/helper.h b/src/script/common/helper.h
index d639d6e16..6491e73cf 100644
--- a/src/script/common/helper.h
+++ b/src/script/common/helper.h
@@ -38,7 +38,8 @@ protected:
* @param index Lua Index to read
* @return read value from Lua
*/
- template <typename T> static T readParam(lua_State *L, int index);
+ template <typename T>
+ static T readParam(lua_State *L, int index);
/**
* Read a value using a template type T from Lua State L and index
@@ -50,5 +51,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);
+ }
};