Sign in to follow this  
S41NT

Callback problem (newbie question!)

Recommended Posts

S41NT    122
Hi! Our team is developing a game engine and we will use callbacks to let script writers deal with collisions and other stuff detected by the engine. So I write a test function which at some point goes like this:
// function to be called
lua_getglobal(CLuaScript::L, l_pcFunctionName);

void *test = (void *)&(a_callback.report);
//pushing collision report onto the stack
lua_pushlightuserdata(CLuaScript::L, &test);

// do the call (0 arguments, 0 result)
lua_pcall(CLuaScript::L, 1, 0, 0);
At the script, theres a function with the specified name and it is called. But I can't get the report back. Then I tried casting IN THE SCRIPT to the correct type: tolua.cast(variable, "Report"); And everything works. I don't want to cast inside the script. How can I make the callback specifying the type of the argument? Thanks very much.

Share this post


Link to post
Share on other sites
S41NT    122
If I understand things correctly, I should assign a metatable to the userdata pushed onto the stack. I tried, but without sucess. So that means I'm still looking for help :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this