register functions before initial lua eval

This commit is contained in:
wanp 2024-10-05 18:40:39 -03:00
parent bd99540280
commit 6844049279

View File

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