Sign in to follow this  

LUA scripts and C callback functions

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

This topic is 3664 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.

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