diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 468af0aa1..ac9b6053d 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -250,12 +250,15 @@ static int lib_userdataType(lua_State *L) // Only callable during script loading static int lib_registerMetatable(lua_State *L) { - static UINT32 nextid = 1; + static UINT16 nextid = 1; if (!lua_lumploading) return luaL_error(L, "This function cannot be called from within a hook or coroutine!"); luaL_checktype(L, 1, LUA_TTABLE); + if (nextid == 0) + luaL_error(L, "Too many metatables registered?! Please consider rewriting your script once you are sober again.\n"); + lua_getfield(L, LUA_REGISTRYINDEX, LREG_METATABLES); // 2 // registry.metatables[metatable] = nextid lua_pushvalue(L, 1); // 3