diff --git a/apps/twnlua/game.c b/apps/twnlua/game.c index 6df50a5..8ce97c2 100644 --- a/apps/twnlua/game.c +++ b/apps/twnlua/game.c @@ -112,6 +112,12 @@ void game_tick(void) { State *state = ctx.udata; bindgen_build_context(state->L); + lua_getglobal(state->L, "ctx"); + if (!lua_isnoneornil(state->L, -1)) { + lua_getfield(state->L, -1, "udata"); + lua_setfield(state->L, -3, "udata"); + } + lua_pop(state->L, 1); lua_setglobal(state->L, "ctx"); lua_getglobal(state->L, "game_tick");