1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Store vector metatable in registry

This commit is contained in:
Jude Melton-Houghton 2022-03-29 12:07:00 -04:00 committed by GitHub
parent 11aab4198b
commit 06d197cdd0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 36 additions and 21 deletions

View file

@ -52,25 +52,12 @@ if (value < F1000_MIN || value > F1000_MAX) { \
/**
* A helper which sets (if available) the vector metatable from builtin as metatable
* for the table on top of the stack
* A helper which sets the vector metatable for the table on top of the stack
*/
static void set_vector_metatable(lua_State *L)
{
// get vector.metatable
lua_getglobal(L, "vector");
if (!lua_istable(L, -1)) {
// there is no global vector table
lua_pop(L, 1);
errorstream << "set_vector_metatable in c_converter.cpp: " <<
"missing global vector table" << std::endl;
return;
}
lua_getfield(L, -1, "metatable");
// set the metatable
lua_setmetatable(L, -3);
// pop vector global
lua_pop(L, 1);
lua_rawgeti(L, LUA_REGISTRYINDEX, CUSTOM_RIDX_VECTOR_METATABLE);
lua_setmetatable(L, -2);
}
void push_v3f(lua_State *L, v3f p)