MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / init

Method init

source/game/scripting/StarLuaComponents.cpp:74–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74bool 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
105void LuaBaseComponent::uninit() {
106 if (m_context) {

Callers

nothing calls this directly

Calls 8

errorFunction · 0.85
StringClass · 0.85
containsPathMethod · 0.80
invokePathMethod · 0.80
outputExceptionFunction · 0.50
printExceptionFunction · 0.50
resetMethod · 0.45
createContextMethod · 0.45

Tested by

no test coverage detected