diff options
Diffstat (limited to 'src/script/lua_api/l_base.cpp')
-rw-r--r-- | src/script/lua_api/l_base.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/script/lua_api/l_base.cpp b/src/script/lua_api/l_base.cpp index e62aa2368..052f661bb 100644 --- a/src/script/lua_api/l_base.cpp +++ b/src/script/lua_api/l_base.cpp @@ -90,3 +90,15 @@ bool ModApiBase::isNaN(lua_State *L, int idx) { return lua_type(L, idx) == LUA_TNUMBER && std::isnan(lua_tonumber(L, idx)); } + +/* + * Read template functions + */ +template<> +float ModApiBase::readParam(lua_State *L, int index) +{ + if (isNaN(L, index)) + throw LuaError("NaN value is not allowed."); + + return (float) luaL_checknumber(L, index); +} |