Jump to content
  • Advertisement
Sign in to follow this  
JC-JuiCe

luabind::call_function error

This topic is 4146 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I have recently started to experiment with LUA 5.1 and luabind. But I have encountered a problem that I can't solve. When I use luabind::call_function to call a lua function with a class as parameter the debugger gives me this error: Unhandled exception at 0x7c812a5b in LuaTest.exe: Microsoft C++ exception: luabind::error at memory location 0x0013fd4c.. Here is some example code that produces the error for me
#include <iostream>

extern "C"
{
	#include <lua.h>
	#include <lualib.h>
	#include <lauxlib.h>
}

#include <luabind/luabind.hpp>

class Test
{
public:

	void Print()
	{
		std::cout << "This is a test" << std::endl;
	}

};

extern "C" int InitLuabind(lua_State* L)
{
    using namespace luabind;

    open(L);

    module(L)
    [
		class_<Test>("Test")
		.def(constructor<>())
		.def("Print", &Test::Print)
    ];

    return 0;
}

int main()
{
	lua_State *L;
	L = lua_open();

	luaL_openlibs(L);

	InitLuabind(L);

	luaL_loadfile(L, "test.lua");
	Test t;

	luabind::call_function<void>(L, "test", &t); // Call function 'test' with t as parameter

	system("pause");

	return 0;
}

and the content of test.lua...
function test(e)
	e:Print()
end

Is it my code or should this work?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!