mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-12-22 19:30:05 +00:00
start LuaManager
for now it runs a simple test script on init()
This commit is contained in:
parent
27ccda5b10
commit
95f2920f5c
15
src/lua/Manager.cpp
Normal file
15
src/lua/Manager.cpp
Normal 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
7
src/lua/Manager.hpp
Normal file
@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "lua/Thread.hpp"
|
||||
|
||||
namespace LuaManager {
|
||||
void init();
|
||||
}
|
14
src/lua/Thread.hpp
Normal file
14
src/lua/Thread.hpp
Normal 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) {}
|
||||
};
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user