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

Problems with LuaPlus CallDispatcher

Started by Ludi83 Sep 16, 2005 at 6:23 PM 0 replies 900+ views
Original Post
Ludi83
Ludi83
Hi, before I ask my question, here is some code:

class CTEST {

public:

    void TEST(int test) {

		printf("value %i\n", val);
		val = test;
    }
	int val;
};

	CTEST test;

	test.val = 0;
	lua_pushstring(m_Luastate, "TEST");
	lua_pushdirectclosure(m_Luastate, test, CTEST::TEST, 0);
	lua_settable(m_Luastate, LUA_GLOBALSINDEX);
	
	lua_dostring(m_Luastate, "TEST(1)");
	lua_dostring(m_Luastate, "TEST(2)");
	test.TEST(3);
	test.TEST(4);


Okay, all I do here is to create a class, register it with the CD and then calling the function 2times in Lua and then normally in C++. Okay, I would say, the output should look like: val = 0 val = 1 val = 2 val = 3 But, it doesn't :) When I start this under VS.NEt 2003 I get: value 0 value 1 value 0 value 3 Why? Greetings
Ludi83
Ludi83
Okay, now I use LuaBind, easy to use and and it works :)

Topic Locked

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

Sign in to reply to this topic.