summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src/environment.h
blob: 4693376ebea18a25c50c732f283fa5631919e222 (plain)
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
#pragma once

class CMLuaEnvironment : public CMPluginBase, public MZeroedObject
{
private:
	CMPluginBase *m_plugin;

	std::map<HANDLE, int> m_hookRefs;
	std::map<HANDLE, int> m_serviceRefs;

protected:
	void CreateEnvironmentTable();

	wchar_t* Error();

public:
	lua_State *L;

	CMLuaEnvironment(lua_State *L);

	int Unload() override;

	static CMLuaEnvironment* GetEnvironment(lua_State *L);
	static HPLUGIN GetEnvironmentId(lua_State *L);

	HANDLE HookEvent(const char *name, int ref);
	int UnhookEvent(HANDLE hHook);

	HANDLE CreateServiceFunction(const char *name, int ref);
	void DestroyServiceFunction(HANDLE hService);

	int Call();
	int Eval(const wchar_t *script);
	int Exec(const wchar_t *path);
};