Calling C/C++ not contained inside a .dll

delrocco at gmail.com delrocco at gmail.com
Sun May 15 12:43:06 EDT 2005


Hello,

I really appreciate anyone who has time to read this and help, Thanks
up front.
I'm very new to python, having picked it up for the first time a week
ago, but I feel I'm very close to getting this working.

Here's what I'm trying to do:
 - call python scripts from game code
 - have those called scripts call functions that are back in game code

The first part looks easy enough to do if I use, ppembed or something.
The second part has been driving me nuts, because I thought I had a
solution and now I just feel defeated.

I've gotten SWIG working and built a .dll extension with functions in
it to be loaded from python and communicate with my game.  I've
successfully imported it into a python interpreter and called
functions in it.

The problem is I haven't figured out how to make those calls call
functions in my game application.  If I load the same .dll from my
game and pass in a structure full of function pointers, the
communication from the game to the .dll works... but then the module I
am using in the python interpreter is not the same one, as if its a
copy.

My question is..
How do I get python scripts to call functions in my game code without
having to build a .dll that has the entire meat of my game inside of
it?  Ultimately I want to be able to load scripts from my game and
have those scripts call functions in my game code.

Example:
- game calls script's "onDamage" function
- script sets various variables, and then calls "swapModel" function in
game

Thanks,
Joe




More information about the Python-list mailing list