lua runnables update

This commit is contained in:
MihailRis
2024-05-04 23:23:04 +03:00
parent bab806c2f8
commit f9dd865bee
4 changed files with 42 additions and 10 deletions
+10 -7
View File
@@ -3,12 +3,15 @@
#include <iostream>
#include "lua/LuaState.h"
#include "../../debug/Logger.hpp"
#include "../../util/stringutil.h"
namespace scripting {
extern lua::LuaState* state;
}
static debug::Logger logger("scripting_func");
using namespace scripting;
runnable scripting::create_runnable(
@@ -16,13 +19,13 @@ runnable scripting::create_runnable(
const std::string& src,
const std::string& file
) {
return [=](){
try {
state->execute(*env, src, file);
} catch (const lua::luaerror& err) {
std::cerr << err.what() << std::endl;
}
};
try {
state->loadbuffer(*env, src, file);
return state->createLambda();
} catch (const lua::luaerror& err) {
logger.error() << err.what();
return [](){};
}
}
static bool processCallback(