Skip to main content
GameDev.net gamedev.net
🔒 Locked

LUABind and classes

Started by Andybean9 Oct 19, 2005 at 9:37 PM 1 replies 1k views
Original Post
Andybean9
Andybean9
Hi all, I'm trying to set up a class that controls the scripting engine, like so:

class ScriptEngine
{
private:

	lua_State *m_pLua;

	static ScriptEngine *m_pInstance;

	ScriptEngine()
	{
		m_pLua = lua_open();
	}

public:

	~ScriptEngine()
	{
		lua_close(m_pLua);
	}

	static ScriptEngine *GetInstance() { if(!m_pInstance) m_pInstance = new ScriptEngine; return m_pInstance; }

	lua_State *GetLuaState() { return m_pLua; }
};

And then I have a cut scene class I'm working on that looks like this:

class CutSceneMgr
{
private:


public:

	CutSceneMgr()
	{
	}

	~CutSceneMgr()
	{
	}

	void SetupLuaBinds()
	{
		luabind::module(ScriptEngine::GetInstance()->GetLuaState()) [
			luabind::class_<CutSceneMgr>("CutSceneManager")
		 .def("Do", Do)
		 ];
	}

	void Do() { }
};

and my Main.cpp looks like this:

int _tmain(int argc, _TCHAR* argv[])
{
	ScriptEngine *pScriptEngine = ScriptEngine::GetInstance();

	CutSceneMgr cut;
	cut.SetupLuaBinds();

	return 0;
}

The problem is when I run the program it breaks and LUA spits this out, I can't seem to figure out what is going on. Assertion failed: m_stack == lua_gettop(m_L), file e:\devel\libraries\luabind-2005.06.15\include\luabind\detail\debuh.hpp, line 42 If anyone could help point me in the right direction as to what the problem is I would appreciate it! Thanks
John Schultz
John Schultz
Try adding luabind::open(m_pLua) before calling any luabind code.
Also see blankdev's thread: LuaBind Woes (has open(), close() calls).
Andybean9
Andybean9
OMG!! I'm an idiot! thanks for pointing that out to me!!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.