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

D

delrocco

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
 
M

Mike Meyer

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.

This is a pretty generic question for any application: how do I invoke
my applications functionality from a python script.

You want to embed python in your game, and then extend the embedded
python interpter. This is covered in the chapter with pretty much that
as the title: <url:
http://docs.python.org/ext/extending-with-embedding.html >.

<mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top