Merge branch 'main' of https://git.poto.cafe/wanp/townengine
This commit is contained in:
commit
b9f2de1e28
@ -285,13 +285,15 @@ void game_tick(void) {
|
|||||||
lua_register(state->L, "text", b_text);
|
lua_register(state->L, "text", b_text);
|
||||||
|
|
||||||
/* now finally get to running the code */
|
/* now finally get to running the code */
|
||||||
state->game_buf_size = file_to_bytes("/scripts/game.lua", &state->game_buf);
|
unsigned char *game_buf = NULL;
|
||||||
if (luaL_loadbuffer(state->L, (char *)state->game_buf, state->game_buf_size, "game.lua") == LUA_OK) {
|
size_t game_buf_size = file_to_bytes("/scripts/game.lua", &game_buf);
|
||||||
|
if (luaL_loadbuffer(state->L, (char *)game_buf, game_buf_size, "game.lua") == LUA_OK) {
|
||||||
if (lua_pcall(state->L, 0, 0, 0) != LUA_OK) {
|
if (lua_pcall(state->L, 0, 0, 0) != LUA_OK) {
|
||||||
log_critical("%s", lua_tostring(state->L, -1));
|
log_critical("%s", lua_tostring(state->L, -1));
|
||||||
lua_pop(state->L, 1);
|
lua_pop(state->L, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
free(game_buf);
|
||||||
/* from this point we have access to everything defined in lua */
|
/* from this point we have access to everything defined in lua */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,7 +309,6 @@ void game_tick(void) {
|
|||||||
|
|
||||||
void game_end(void) {
|
void game_end(void) {
|
||||||
State *state = ctx.udata;
|
State *state = ctx.udata;
|
||||||
free(state->game_buf);
|
|
||||||
lua_close(state->L);
|
lua_close(state->L);
|
||||||
free(state);
|
free(state);
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
|
|
||||||
typedef struct State {
|
typedef struct State {
|
||||||
lua_State *L;
|
lua_State *L;
|
||||||
unsigned char *game_buf;
|
|
||||||
size_t game_buf_size;
|
|
||||||
} State;
|
} State;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user