LUA scripts and C callback functions

This topic is 3913 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

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

1. 1
2. 2
JoeJ
18
3. 3
4. 4
frob
11
5. 5

• 13
• 16
• 13
• 20
• 13
• Forum Statistics

• Total Topics
632187
• Total Posts
3004649

×