start LuaManager

for now it runs a simple test script on init()
This commit is contained in:
CPunch 2023-12-13 16:42:40 -06:00
parent 27ccda5b10
commit 95f2920f5c
4 changed files with 39 additions and 0 deletions

15
src/lua/Manager.cpp Normal file
View File

@ -0,0 +1,15 @@
#include "lua/Manager.hpp"
#include <iostream>
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);
}
}
}

7
src/lua/Manager.hpp Normal file
View File

@ -0,0 +1,7 @@
#pragma once
#include "lua/Thread.hpp"
namespace LuaManager {
void init();
}

14
src/lua/Thread.hpp Normal file
View File

@ -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) {}
};

View File

@ -24,6 +24,8 @@
#include "Eggs.hpp" #include "Eggs.hpp"
#include "Rand.hpp" #include "Rand.hpp"
#include "lua/Manager.hpp"
#include "settings.hpp" #include "settings.hpp"
#include "sandbox/Sandbox.hpp" #include "sandbox/Sandbox.hpp"
@ -138,6 +140,7 @@ int main() {
Trading::init(); Trading::init();
Database::open(); Database::open();
LuaManager::init();
switch (settings::EVENTMODE) { switch (settings::EVENTMODE) {
case 0: break; // no event case 0: break; // no event