|
|
|
|
@ -33,10 +33,8 @@ namespace lunarium
|
|
|
|
|
|
|
|
|
|
OpRes ScriptManager::Initialize()
|
|
|
|
|
{
|
|
|
|
|
mCat = Logger::RegisterCategory("LUA");
|
|
|
|
|
mCat = Logger::RegisterCategory("SCRIPT");
|
|
|
|
|
|
|
|
|
|
mState.open_libraries(sol::lib::base, sol::lib::package);
|
|
|
|
|
// mState.script("print('test puppy says: bark bark bark!')");
|
|
|
|
|
|
|
|
|
|
return OpRes::OK();
|
|
|
|
|
}
|
|
|
|
|
@ -49,18 +47,7 @@ namespace lunarium
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: Use the state to run the script and check for errors
|
|
|
|
|
auto result = mpInstance->mState.script(code, [](lua_State*, sol::protected_function_result pfr) {
|
|
|
|
|
return pfr;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!result.valid())
|
|
|
|
|
{
|
|
|
|
|
sol::error err = result;
|
|
|
|
|
Logger::Warn(mpInstance->mCat, "LUA script has errors");
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << "LUA code has error. CODE:\n" << code << "\nEND CODE -- ERROR: " << err.what();
|
|
|
|
|
return OpRes::Fail(oss.str().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return OpRes::OK();
|
|
|
|
|
}
|
|
|
|
|
|