/apps/twnlua: ctx.udata preservation (not yet for reload case)

This commit is contained in:
veclavtalica 2025-01-11 16:22:41 +03:00
parent 777a06a002
commit 41d0e24780

View File

@ -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");