| 72 | } |
| 73 | |
| 74 | bool LuaBaseComponent::init() { |
| 75 | uninit(); |
| 76 | |
| 77 | if (!m_luaRoot) |
| 78 | return false; |
| 79 | |
| 80 | m_error.reset(); |
| 81 | try { |
| 82 | m_context = m_luaRoot->createContext(m_scripts); |
| 83 | } catch (LuaException const& e) { |
| 84 | Logger::error("Exception while creating lua context for scripts '{}': {}", m_scripts, outputException(e, true)); |
| 85 | m_error = String(printException(e, false)); |
| 86 | m_context.reset(); |
| 87 | return false; |
| 88 | } |
| 89 | contextSetup(); |
| 90 | |
| 91 | if (m_context->containsPath("init")) { |
| 92 | try { |
| 93 | m_context->invokePath("init"); |
| 94 | } catch (LuaException const& e) { |
| 95 | Logger::error("Exception while calling script init: {}", outputException(e, true)); |
| 96 | m_error = String(printException(e, false)); |
| 97 | m_context.reset(); |
| 98 | return false; |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | return true; |
| 103 | } |
| 104 | |
| 105 | void LuaBaseComponent::uninit() { |
| 106 | if (m_context) { |
nothing calls this directly
no test coverage detected