summaryrefslogtreecommitdiffstats
path: root/src/Bindings/LuaChunkStay.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-02-11 09:07:08 +0100
committerMattes D <github@xoft.cz>2014-02-11 09:07:08 +0100
commit1f96454b9cc35e76bfab2fb5dbea5dc34b0fe28e (patch)
tree0cacd6ad93e9d02c0228bc314834bd7e8edae1bc /src/Bindings/LuaChunkStay.h
parentMerge pull request #660 from worktycho/boatsFix (diff)
parentDebuggers: Updated messaging functions (diff)
downloadcuberite-1f96454b9cc35e76bfab2fb5dbea5dc34b0fe28e.tar
cuberite-1f96454b9cc35e76bfab2fb5dbea5dc34b0fe28e.tar.gz
cuberite-1f96454b9cc35e76bfab2fb5dbea5dc34b0fe28e.tar.bz2
cuberite-1f96454b9cc35e76bfab2fb5dbea5dc34b0fe28e.tar.lz
cuberite-1f96454b9cc35e76bfab2fb5dbea5dc34b0fe28e.tar.xz
cuberite-1f96454b9cc35e76bfab2fb5dbea5dc34b0fe28e.tar.zst
cuberite-1f96454b9cc35e76bfab2fb5dbea5dc34b0fe28e.zip
Diffstat (limited to 'src/Bindings/LuaChunkStay.h')
-rw-r--r--src/Bindings/LuaChunkStay.h73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/Bindings/LuaChunkStay.h b/src/Bindings/LuaChunkStay.h
new file mode 100644
index 000000000..49ab9a0ad
--- /dev/null
+++ b/src/Bindings/LuaChunkStay.h
@@ -0,0 +1,73 @@
+
+// LuaChunkStay.h
+
+// Declares the cLuaChunkStay class representing a cChunkStay binding for plugins, used by cWorld:ChunkStay() Lua API
+
+
+
+
+
+#pragma once
+
+#include "LuaState.h"
+#include "../ChunkStay.h"
+
+
+
+
+
+// fwd:
+class cPluginLua;
+
+
+
+
+
+class cLuaChunkStay
+ : public cChunkStay
+{
+ typedef cChunkStay super;
+
+public:
+ cLuaChunkStay(cPluginLua & a_Plugin);
+
+ ~cLuaChunkStay() { }
+
+ /** Adds chunks in the specified on-stack Lua table.
+ Returns true if any chunk added, false (plus log warning) if none. */
+ bool AddChunks(int a_ChunkCoordTableStackPos);
+
+ /** Enables the ChunkStay for the specified chunkmap, with the specified Lua callbacks. */
+ void Enable(cChunkMap & a_ChunkMap, int a_OnChunkAvailableStackPos, int a_OnAllChunksAvailableStackPos);
+
+protected:
+ /** The plugin which has created the ChunkStay, via cWorld:ChunkStay() binding method. */
+ cPluginLua & m_Plugin;
+
+ /** The Lua state associated with the callbacks. Only valid when enabled. */
+ cLuaState * m_LuaState;
+
+ /** The Lua function to call in OnChunkAvailable. Only valid when enabled. */
+ cLuaState::cRef m_OnChunkAvailable;
+
+ /** The Lua function to call in OnAllChunksAvailable. Only valid when enabled. */
+ cLuaState::cRef m_OnAllChunksAvailable;
+
+
+ // cChunkStay overrides:
+ virtual void OnChunkAvailable(int a_ChunkX, int a_ChunkZ) override;
+ virtual bool OnAllChunksAvailable(void) override;
+ virtual void OnDisabled(void) override;
+
+ /** Adds a single chunk coord from the table at the top of the Lua stack.
+ Expects the top element to be a table, checks that it contains two numbers.
+ Uses those two numbers as chunk coords appended to m_Chunks.
+ If the coords are already present, gives a warning and ignores the pair.
+ The a_Index parameter is only for the error messages. */
+ void AddChunkCoord(cLuaState & a_LuaState, int a_Index);
+} ;
+
+
+
+
+