Change ExecuteScript and ExecuteString to return void and throw a TENScriptException on error. Remove my old comments which didn't really add info. Implement SetSettings.

This commit is contained in:
hispidence 2021-08-03 15:12:24 +01:00
parent efc91a8e34
commit 58a424e52f
4 changed files with 26 additions and 39 deletions

View file

@ -6,27 +6,20 @@ LuaHandler::LuaHandler(sol::state* lua) {
m_lua = lua;
}
bool LuaHandler::ExecuteScript(std::string const& luaFilename, std::string & message) {
auto result = m_lua->safe_script_file(luaFilename);
//auto result = m_lua->safe_script_file(luaFilename, sol::environment(m_lua->lua_state(), sol::create, m_lua->globals()), sol::script_pass_on_error);
void LuaHandler::ExecuteScript(std::string const& luaFilename) {
auto result = m_lua->safe_script_file(luaFilename, sol::script_pass_on_error);
if (!result.valid())
{
sol::error error = result;
message = error.what();
return false;
throw TENScriptException{ error.what() };
}
return true;
}
bool LuaHandler::ExecuteString(std::string const & command, std::string& message) {
void LuaHandler::ExecuteString(std::string const & command) {
auto result = m_lua->safe_script(command, sol::environment(m_lua->lua_state(), sol::create, m_lua->globals()), sol::script_pass_on_error);
if (!result.valid())
{
sol::error error = result;
message = error.what();
return false;
throw TENScriptException{ error.what() };
}
return true;
}