diff options
Diffstat (limited to 'src/Bindings/LuaChunkStay.h')
-rw-r--r-- | src/Bindings/LuaChunkStay.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/Bindings/LuaChunkStay.h b/src/Bindings/LuaChunkStay.h new file mode 100644 index 000000000..e9d87d7f6 --- /dev/null +++ b/src/Bindings/LuaChunkStay.h @@ -0,0 +1,58 @@ + +// LuaChunkStay.h + +// Declares the cLuaChunkStay class representing a cChunkStay binding for plugins + + + + + +#pragma once + +#include "LuaState.h" +#include "../ChunkStay.h" + + + + + +// tolua_begin +class cLuaChunkStay + : public cChunkStay +{ + typedef cChunkStay super; + +public: + // Allow Lua to construct objects of this class: + cLuaChunkStay(void) {} + + // Allow Lua to garbage-collect objects of this class: + ~cLuaChunkStay() {} + + // tolua_end + + /** Enabled the ChunkStay for the specified world, with the specified Lua callbacks. + Exported in ManualBindings. */ + void Enable( + cWorld & a_World, cLuaState & a_LuaState, + const cLuaState::cRef & a_OnChunkAvailable, const cLuaState::cRef & a_OnAllChunksAvailable + ); + +protected: + /** 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 void OnAllChunksAvailable(void) override; +} ; // tolua_export + + + + |