From 7cf075d1a60b27dd76d6acd928f78761f569a251 Mon Sep 17 00:00:00 2001 From: j4nk Date: Sun, 16 Mar 2025 22:05:09 -0400 Subject: [PATCH] Pass listening port to lua when calling oct_init --- main.c | 3 ++- test_args.lua => test_oct_init.lua | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) rename test_args.lua => test_oct_init.lua (77%) diff --git a/main.c b/main.c index f3d6f96..94f67e3 100644 --- a/main.c +++ b/main.c @@ -214,7 +214,8 @@ int initialize_everything(char* lua_file) { OCT_LOG_INFO("Begin running oct_init()"); lua_getglobal(L, "oct_init"); lua_pushstring(L, lua_args); - if (lua_pcall(L, 1, 2, 0) != LUA_OK) { + lua_pushinteger(L, atoi(config.port)); + if (lua_pcall(L, 2, 2, 0) != LUA_OK) { OCT_LOG_ERROR("%s", luaL_checkstring(L, -1)); deinitialize_everything(); return 0; diff --git a/test_args.lua b/test_oct_init.lua similarity index 77% rename from test_args.lua rename to test_oct_init.lua index 527439b..26f1ddf 100644 --- a/test_args.lua +++ b/test_oct_init.lua @@ -1,8 +1,9 @@ require("oct_utils") require("termbox_defs") -function oct_init(args) +function oct_init(args, port) OCT_LOG_ERROR("Starting oct_init") + OCT_LOG_ERROR("Port: " .. port) OCT_LOG_ERROR("Received args: " .. args) return OCT_NOT_NEEDS_NETWORKING, OCT_NOT_NEEDS_TERMBOX end