diff --git a/src/modules/graphics/wrap_Graphics.cpp b/src/modules/graphics/wrap_Graphics.cpp index a423453a4..beab3df90 100644 --- a/src/modules/graphics/wrap_Graphics.cpp +++ b/src/modules/graphics/wrap_Graphics.cpp @@ -2395,6 +2395,8 @@ int w_readbackTexture(lua_State *L) int slice = 0; if (t->getTextureType() != TEXTURE_2D) slice = (int) luaL_checkinteger(L, 2) - 1; + else if (!lua_isnoneornil(L, 2) && lua_type(L, 2) != LUA_TNUMBER) + luaL_argerror(L, 2, "number or nil expected"); int mipmap = (int) luaL_optinteger(L, 3, 1) - 1; @@ -2433,6 +2435,8 @@ int w_readbackTextureAsync(lua_State *L) int slice = 0; if (t->getTextureType() != TEXTURE_2D) slice = (int) luaL_checkinteger(L, 2) - 1; + else if (!lua_isnoneornil(L, 2) && lua_type(L, 2) != LUA_TNUMBER) + luaL_argerror(L, 2, "number or nil expected"); int mipmap = (int) luaL_optinteger(L, 3, 1) - 1;