mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Modernize lua read (part 1): C++ templating insurance (#7394)
* Modernize lua read (part 1): C++ templating assurance Implement the float reader
This commit is contained in:
parent
86b19f2849
commit
180e551c56
9 changed files with 43 additions and 21 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue