summaryrefslogtreecommitdiffstats
path: root/src/Bindings/LuaChunkStay.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-02-09 18:56:16 +0100
committermadmaxoft <github@xoft.cz>2014-02-09 18:56:16 +0100
commit9455f59b1100f3db2c5b1e88bb9d1f6a01664721 (patch)
tree5a6fcca8728b60dc357baf104009eae1bccdb4d4 /src/Bindings/LuaChunkStay.cpp
parentcLuaState::cRef can be unbound and re-bound. (diff)
downloadcuberite-9455f59b1100f3db2c5b1e88bb9d1f6a01664721.tar
cuberite-9455f59b1100f3db2c5b1e88bb9d1f6a01664721.tar.gz
cuberite-9455f59b1100f3db2c5b1e88bb9d1f6a01664721.tar.bz2
cuberite-9455f59b1100f3db2c5b1e88bb9d1f6a01664721.tar.lz
cuberite-9455f59b1100f3db2c5b1e88bb9d1f6a01664721.tar.xz
cuberite-9455f59b1100f3db2c5b1e88bb9d1f6a01664721.tar.zst
cuberite-9455f59b1100f3db2c5b1e88bb9d1f6a01664721.zip
Diffstat (limited to '')
-rw-r--r--src/Bindings/LuaChunkStay.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/Bindings/LuaChunkStay.cpp b/src/Bindings/LuaChunkStay.cpp
new file mode 100644
index 000000000..606f7694f
--- /dev/null
+++ b/src/Bindings/LuaChunkStay.cpp
@@ -0,0 +1,52 @@
+
+// LuaChunkStay.cpp
+
+// Implements the cLuaChunkStay class representing a cChunkStay binding for plugins
+
+#include "Globals.h"
+#include "LuaChunkStay.h"
+#include "../World.h"
+
+
+
+
+
+void cLuaChunkStay::Enable(
+ cWorld & a_World, cLuaState & a_LuaState,
+ const cLuaState::cRef & a_OnChunkAvailable, const cLuaState::cRef & a_OnAllChunksAvailable
+)
+{
+ if (m_LuaState != NULL)
+ {
+ LOGWARNING("LuaChunkStay: Already enabled. Ignoring this call.");
+ a_LuaState.LogStackTrace();
+ return;
+ }
+ m_LuaState = &a_LuaState;
+ m_OnChunkAvailable = a_OnAllChunksAvailable;
+ m_OnAllChunksAvailable = a_OnAllChunksAvailable;
+ super::Enable(*a_World.GetChunkMap());
+}
+
+
+
+
+
+void cLuaChunkStay::OnChunkAvailable(int a_ChunkX, int a_ChunkZ)
+{
+ m_LuaState->Call(m_OnChunkAvailable, a_ChunkX, a_ChunkZ);
+}
+
+
+
+
+
+void cLuaChunkStay::OnAllChunksAvailable(void)
+{
+ m_LuaState->Call(m_OnAllChunksAvailable);
+}
+
+
+
+
+