ErrCode LuaEngine::VExecuteExpression(const UString& expression) { ErrCode error = ErrCode::ERR_SUCCESS; if (expression.empty()) { DebugPrintF(VTEXT("SCRIPT EMPTY")); return ErrCode::ERR_NULL_PATH; } std::string _exp = UStringToStd(expression); int state = luaL_dostring(m_L, _exp.c_str()); error = ReportScriptErrors(state); if (CheckError(error)) { DebugPrintF(VTEXT("Failed to execute script expression")); } return error; }
bool LuaEngine::ExecuteExpression(UString expression) { LuaEngine& _engine = LuaEngine::instance(); if (expression.empty()) { DebugPrintF(VTEXT("SCRIPT EMPTY")); return false; } std::string _exp = UStringToStd(expression); int state = luaL_dostring(_engine.m_L, _exp.c_str()); if (!ReportScriptErrors(state)) { DebugPrintF(VTEXT("Failed to execute script expression")); return false; } return true; }
ErrCode LuaEngine::VExecuteFile(const UString& path) { ErrCode error = ErrCode::ERR_SUCCESS; if (path.empty()) { DebugPrintF(VTEXT("Failed to execute script file: NULL PATH")); return ErrCode::ERR_NULL_PATH; } /*try and execute script file*/ std::string _path = UStringToStd(path); int state = luaL_dofile(m_L, _path.c_str()); error = ReportScriptErrors(state); if (CheckError(error)) { DebugPrintF(VTEXT("Failed to execute script file")); } return error; }