Functions defined in WFL can now access the function table they are defined in as a Lua global variable

This commit is contained in:
Celtic Minstrel 2024-09-29 12:46:13 -04:00
parent 141c26d955
commit cf5e2b1d2c

View file

@ -616,6 +616,9 @@ static int impl_fcntb_set(lua_State* L)
lua_setfield(L, -2, w);
}
lua_setfield(L, -2, "wml");
// Also add the function table itself as a global
lua_pushvalue(L, 1);
lua_setfield(L, -2, "wfl_functions");
lua_setupvalue(L, -2, 1);
}
lua_rawsetp(L, LUA_REGISTRYINDEX, fcn.get());