diff --git a/src/lua/Manager.cpp b/src/lua/Manager.cpp new file mode 100644 index 0000000..af89e6d --- /dev/null +++ b/src/lua/Manager.cpp @@ -0,0 +1,15 @@ +#include "lua/Manager.hpp" + +#include + +namespace LuaManager { + void init() { + lua_State *L = luaL_newstate(); + luaL_openlibs(L); + + if (luaL_dostring(L, "print(\"Hello from Lua!\")")) { + std::cout << "Lua error: " << lua_tostring(L, -1) << std::endl; + lua_pop(L, 1); + } + } +} \ No newline at end of file diff --git a/src/lua/Manager.hpp b/src/lua/Manager.hpp new file mode 100644 index 0000000..7608505 --- /dev/null +++ b/src/lua/Manager.hpp @@ -0,0 +1,7 @@ +#pragma once + +#include "lua/Thread.hpp" + +namespace LuaManager { + void init(); +} \ No newline at end of file diff --git a/src/lua/Thread.hpp b/src/lua/Thread.hpp new file mode 100644 index 0000000..c115939 --- /dev/null +++ b/src/lua/Thread.hpp @@ -0,0 +1,14 @@ +#pragma once + +extern "C" { +#include "lua.h" +#include "lualib.h" +#include "lauxlib.h" +} + +struct LuaThread { + lua_State *L; + int ref; + + LuaThread(lua_State *L, int ref) : L(L), ref(ref) {} +}; \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 288e537..0b183cb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -24,6 +24,8 @@ #include "Eggs.hpp" #include "Rand.hpp" +#include "lua/Manager.hpp" + #include "settings.hpp" #include "sandbox/Sandbox.hpp" @@ -138,6 +140,7 @@ int main() { Trading::init(); Database::open(); + LuaManager::init(); switch (settings::EVENTMODE) { case 0: break; // no event