summaryrefslogtreecommitdiffstats
path: root/source/Plugin_NewLua.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-02-05 20:57:22 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-02-05 20:57:22 +0100
commitdedb414a50328bf00462409d14d8917ff24844be (patch)
tree8024df89792a668ad675730b124429c4f03dc1dd /source/Plugin_NewLua.cpp
parentBiomeVisualiser: initial import (diff)
downloadcuberite-dedb414a50328bf00462409d14d8917ff24844be.tar
cuberite-dedb414a50328bf00462409d14d8917ff24844be.tar.gz
cuberite-dedb414a50328bf00462409d14d8917ff24844be.tar.bz2
cuberite-dedb414a50328bf00462409d14d8917ff24844be.tar.lz
cuberite-dedb414a50328bf00462409d14d8917ff24844be.tar.xz
cuberite-dedb414a50328bf00462409d14d8917ff24844be.tar.zst
cuberite-dedb414a50328bf00462409d14d8917ff24844be.zip
Diffstat (limited to '')
-rw-r--r--source/Plugin_NewLua.cpp92
1 files changed, 90 insertions, 2 deletions
diff --git a/source/Plugin_NewLua.cpp b/source/Plugin_NewLua.cpp
index ed66f1d28..d83a88f96 100644
--- a/source/Plugin_NewLua.cpp
+++ b/source/Plugin_NewLua.cpp
@@ -237,10 +237,10 @@ bool cPlugin_NewLua::OnChat(cPlayer * a_Player, const AString & a_Message)
-bool cPlugin_NewLua::OnChunkGenerated(cWorld * a_World, int a_ChunkX, int a_ChunkZ)
+bool cPlugin_NewLua::OnChunkAvailable(cWorld * a_World, int a_ChunkX, int a_ChunkZ)
{
cCSLock Lock(m_CriticalSection);
- const char * FnName = GetHookFnName(cPluginManager::HOOK_CHUNK_GENERATED);
+ const char * FnName = GetHookFnName(cPluginManager::HOOK_CHUNK_AVAILABLE);
ASSERT(FnName != NULL);
if (!PushFunction(FnName))
{
@@ -265,6 +265,35 @@ bool cPlugin_NewLua::OnChunkGenerated(cWorld * a_World, int a_ChunkX, int a_Chun
+bool cPlugin_NewLua::OnChunkGenerated(cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc)
+{
+ cCSLock Lock(m_CriticalSection);
+ const char * FnName = GetHookFnName(cPluginManager::HOOK_CHUNK_GENERATED);
+ ASSERT(FnName != NULL);
+ if (!PushFunction(FnName))
+ {
+ return false;
+ }
+
+ tolua_pushusertype(m_LuaState, a_World, "cWorld");
+ tolua_pushnumber (m_LuaState, a_ChunkX);
+ tolua_pushnumber (m_LuaState, a_ChunkZ);
+ tolua_pushusertype(m_LuaState, a_ChunkDesc, "cChunkDesc");
+
+ if (!CallFunction(4, 1, FnName))
+ {
+ return false;
+ }
+
+ bool bRetVal = (tolua_toboolean(m_LuaState, -1, 0) > 0);
+ lua_pop(m_LuaState, 1);
+ return bRetVal;
+}
+
+
+
+
+
bool cPlugin_NewLua::OnChunkGenerating(cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_pLuaChunk)
{
cCSLock Lock(m_CriticalSection);
@@ -294,6 +323,62 @@ bool cPlugin_NewLua::OnChunkGenerating(cWorld * a_World, int a_ChunkX, int a_Chu
+bool cPlugin_NewLua::OnChunkUnloaded(cWorld * a_World, int a_ChunkX, int a_ChunkZ)
+{
+ cCSLock Lock(m_CriticalSection);
+ const char * FnName = GetHookFnName(cPluginManager::HOOK_CHUNK_UNLOADED);
+ ASSERT(FnName != NULL);
+ if (!PushFunction(FnName))
+ {
+ return false;
+ }
+
+ tolua_pushusertype(m_LuaState, a_World, "cWorld");
+ tolua_pushnumber (m_LuaState, a_ChunkX);
+ tolua_pushnumber (m_LuaState, a_ChunkZ);
+
+ if (!CallFunction(3, 1, FnName))
+ {
+ return false;
+ }
+
+ bool bRetVal = (tolua_toboolean(m_LuaState, -1, 0) > 0);
+ lua_pop(m_LuaState, 1);
+ return bRetVal;
+}
+
+
+
+
+
+bool cPlugin_NewLua::OnChunkUnloading(cWorld * a_World, int a_ChunkX, int a_ChunkZ)
+{
+ cCSLock Lock(m_CriticalSection);
+ const char * FnName = GetHookFnName(cPluginManager::HOOK_CHUNK_UNLOADING);
+ ASSERT(FnName != NULL);
+ if (!PushFunction(FnName))
+ {
+ return false;
+ }
+
+ tolua_pushusertype(m_LuaState, a_World, "cWorld");
+ tolua_pushnumber (m_LuaState, a_ChunkX);
+ tolua_pushnumber (m_LuaState, a_ChunkZ);
+
+ if (!CallFunction(3, 1, FnName))
+ {
+ return false;
+ }
+
+ bool bRetVal = (tolua_toboolean(m_LuaState, -1, 0) > 0);
+ lua_pop(m_LuaState, 1);
+ return bRetVal;
+}
+
+
+
+
+
bool cPlugin_NewLua::OnCollectingPickup(cPlayer * a_Player, cPickup * a_Pickup)
{
cCSLock Lock(m_CriticalSection);
@@ -1276,8 +1361,11 @@ const char * cPlugin_NewLua::GetHookFnName(cPluginManager::PluginHook a_Hook)
{
case cPluginManager::HOOK_BLOCK_TO_PICKUPS: return "OnBlockToPickups";
case cPluginManager::HOOK_CHAT: return "OnChat";
+ case cPluginManager::HOOK_CHUNK_AVAILABLE: return "OnChunkAvailable";
case cPluginManager::HOOK_CHUNK_GENERATED: return "OnChunkGenerated";
case cPluginManager::HOOK_CHUNK_GENERATING: return "OnChunkGenerating";
+ case cPluginManager::HOOK_CHUNK_UNLOADED: return "OnChunkUnloaded";
+ case cPluginManager::HOOK_CHUNK_UNLOADING: return "OnChunkUnloading";
case cPluginManager::HOOK_COLLECTING_PICKUP: return "OnCollectingPickup";
case cPluginManager::HOOK_CRAFTING_NO_RECIPE: return "OnCraftingNoRecipe";
case cPluginManager::HOOK_DISCONNECT: return "OnDisconnect";