Jump to content
  • Advertisement
Sign in to follow this  
S41NT

Callback problem (newbie question!)

This topic is 4617 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! 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
Advertisement
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
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!