summaryrefslogtreecommitdiffstats
path: root/src/Bindings/PluginLua.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-04-19 10:57:41 +0200
committerMattes D <github@xoft.cz>2015-04-19 10:57:41 +0200
commita9b5a6c3a63d8500f3c512574fd802d40b562661 (patch)
treee6d0d362ed42116d6c9deaaa789287f464569514 /src/Bindings/PluginLua.cpp
parentMerge pull request #1869 from mathias-gh/master (diff)
downloadcuberite-a9b5a6c3a63d8500f3c512574fd802d40b562661.tar
cuberite-a9b5a6c3a63d8500f3c512574fd802d40b562661.tar.gz
cuberite-a9b5a6c3a63d8500f3c512574fd802d40b562661.tar.bz2
cuberite-a9b5a6c3a63d8500f3c512574fd802d40b562661.tar.lz
cuberite-a9b5a6c3a63d8500f3c512574fd802d40b562661.tar.xz
cuberite-a9b5a6c3a63d8500f3c512574fd802d40b562661.tar.zst
cuberite-a9b5a6c3a63d8500f3c512574fd802d40b562661.zip
Diffstat (limited to '')
-rw-r--r--src/Bindings/PluginLua.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp
index 9bbac92b0..cb2ea3b45 100644
--- a/src/Bindings/PluginLua.cpp
+++ b/src/Bindings/PluginLua.cpp
@@ -93,7 +93,7 @@ void cPluginLua::Close(void)
-bool cPluginLua::Initialize(void)
+bool cPluginLua::Load(void)
{
cCSLock Lock(m_CriticalSection);
if (!m_LuaState.IsValid())
@@ -144,6 +144,7 @@ bool cPluginLua::Initialize(void)
// Warn if there are no Lua files in the plugin folder:
if (LuaFiles.empty())
{
+ SetLoadError("No lua files found, plugin is probably missing.");
LOGWARNING("No lua files found: plugin %s is missing.", GetName().c_str());
Close();
return false;
@@ -155,6 +156,7 @@ bool cPluginLua::Initialize(void)
AString Path = PluginPath + *itr;
if (!m_LuaState.LoadFile(Path))
{
+ SetLoadError(Printf("Failed to load file %s.", itr->c_str()));
Close();
return false;
}
@@ -164,6 +166,8 @@ bool cPluginLua::Initialize(void)
AString Path = PluginPath + "Info.lua";
if (!m_LuaState.LoadFile(Path))
{
+ SetLoadError("Failed to load file Info.lua.");
+ m_Status = cPluginManager::psError;
Close();
return false;
}
@@ -173,17 +177,20 @@ bool cPluginLua::Initialize(void)
bool res = false;
if (!m_LuaState.Call("Initialize", this, cLuaState::Return, res))
{
+ SetLoadError("Cannot call the Initialize() function.");
LOGWARNING("Error in plugin %s: Cannot call the Initialize() function. Plugin is temporarily disabled.", GetName().c_str());
Close();
return false;
}
if (!res)
{
+ SetLoadError("The Initialize() function failed.");
LOGINFO("Plugin %s: Initialize() call failed, plugin is temporarily disabled.", GetName().c_str());
Close();
return false;
}
+ m_Status = cPluginManager::psLoaded;
return true;
}
@@ -191,6 +198,16 @@ bool cPluginLua::Initialize(void)
+void cPluginLua::Unload(void)
+{
+ super::Unload();
+ Close();
+}
+
+
+
+
+
void cPluginLua::OnDisable(void)
{
cCSLock Lock(m_CriticalSection);