summaryrefslogtreecommitdiffstats
path: root/src/Bindings/LuaChunkStay.h
blob: 0ab73f6694e3d7578be7d426fa26bb9bf06ab4ca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

// 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	
	
	/** Enables the ChunkStay for the specified world, with the specified Lua callbacks.
	Exported in ManualBindings. */
	void Enable(
		cWorld & a_World, lua_State * a_LuaState,
		int a_OnChunkAvailableStackPos, int a_OnAllChunksAvailableStackPos
	);
	
	// tolua_begin
	
	/** Disables the ChunkStay. Cleans up the bound Lua state and callbacks */
	virtual void Disable(void);
	
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_end