From 684404927998b09c6449f6f26f00880daddd37cc Mon Sep 17 00:00:00 2001 From: wanp Date: Sat, 5 Oct 2024 18:40:39 -0300 Subject: [PATCH] register functions before initial lua eval --- apps/lua/game.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/lua/game.c b/apps/lua/game.c index ceb0d27..abd2043 100644 --- a/apps/lua/game.c +++ b/apps/lua/game.c @@ -277,6 +277,11 @@ void game_tick(void) { /* pop package, package.searchers */ lua_pop(state->L, 2); + /* binding */ + lua_register(state->L, "sprite", b_sprite); + lua_register(state->L, "rectangle", b_rectangle); + lua_register(state->L, "text", b_text); + /* now finally get to running the code */ unsigned char *game_buf = NULL; int64_t game_buf_size = file_to_bytes("/scripts/game.lua", &game_buf); @@ -287,11 +292,6 @@ void game_tick(void) { } } /* from this point we have access to everything defined in lua */ - - /* binding */ - lua_register(state->L, "sprite", b_sprite); - lua_register(state->L, "rectangle", b_rectangle); - lua_register(state->L, "text", b_text); } State *state = ctx.udata;