mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
lua runnables update
This commit is contained in:
parent
bab806c2f8
commit
f9dd865bee
4 changed files with 42 additions and 10 deletions
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue