aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 34de048..c170abe 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -43,6 +43,7 @@ SDL_Window *window = nullptr;
SDL_Renderer *renderer = nullptr;
SDL_Event event;
TTF_Font *globalFont = nullptr;
+bool running = true;
// Lua
lua_State *L;
@@ -61,6 +62,7 @@ int l_unqueue_all_textures(lua_State *L);
int l_queue_button_for_render(lua_State *L);
int l_queue_text_for_render(lua_State *L);
int l_get_text_width(lua_State *L);
+int l_quit_game(lua_State* L);
struct QueuedTexture
{
@@ -275,6 +277,11 @@ int l_get_text_width(lua_State *L)
return 1;
}
+int l_quit_game(lua_State* L) {
+ running = false;
+ return 0;
+}
+
void push_keys_to_lua(lua_State *L, bool keys[SDL_NUM_SCANCODES])
{
lua_newtable(L); // create a new table on the stack
@@ -314,6 +321,7 @@ void expose_c_functions()
lua_register(L, "queueButtonForRender", l_queue_button_for_render);
lua_register(L, "queueTextForRender", l_queue_text_for_render);
lua_register(L, "getTextWidth", l_get_text_width);
+ lua_register(L, "quitGame", l_quit_game);
}
int main()
@@ -327,7 +335,6 @@ int main()
luaL_dofile(L, "assets/scripts/mainMenu.lua");
bool keys[SDL_NUM_SCANCODES] = {false};
- bool running = true;
push_keys_to_lua(L, keys);
lua_setglobal(L, "keys");