#ifndef SCRIPT_SYSTEM_H
#define SCRIPT_SYSTEM_H

extern "C"
{
#include "minilua.h"
}

class ScriptSystem
{
public:
	ScriptSystem();
	~ScriptSystem();

	void Init();
	void Shutdown();

	lua_State* GetState();

	void DoFile(const char* filename);
	void DoString(const char* functionName);

	static int PushError(lua_State* L, const char* errorMsg);

	void RegisterGlobalInt(const char* name, int value);

private:
	lua_State* m_State;
};

extern ScriptSystem g_scriptSystem;

struct ScriptThreadInfo
{
	const char* threadname;
	lua_State* state;
};

// Thread manager
class ScriptThreadManager
{
public:
	ScriptThreadManager();
	~ScriptThreadManager();

	lua_State* CreateThread(const char* name, const char* functionName);

private:
	std::vector<ScriptThreadInfo> m_Threads;
};

extern ScriptThreadManager g_ScriptThreadManager;

#endif // !SCRIPT_SYSTEM_H
