Jump to content
  • Advertisement
Sign in to follow this  
Thomo

LUA scripts and C callback functions

This topic is 4003 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

I am using LUA scripting in my game to aid design. I am able to run functions defined in the script successfully. I am also able to call C/C++ functions from the script. However, I have recently come across the following issue which I am unable to resolve and was hoping someone could shed a beam of light :-) I have a Framework.i file where all of the C functions/structures/typedefs are listed so that the they can be used in LUA. The Framework.cpp is compiled automatically using Swig (which I don't know much about) and this compiles all the wrapper functions for LUA. Since adding a C function to this file I have run into a problem. The C function defined in Framework.i looks like this
typedef void (*pCB) ();
void RegisterCallback(char* string1, char* string2, pCB pCallback);

I then run the LUA script like this:
Framework.RegisterCallback("Foo", "Bar", Framework.MyCallback)

Where MyCallback is a C function with it's prototype also listed in Framework.i When the program runs it crashes and the LUA output merely states that the third parameter is 'Missing/Incorrect'. I can't for the life of me figure out what's wrong. Would be grateful if someone could help. Cheers. Thomo

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!