By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,671 Members | 1,623 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,671 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
de******@gmail.com writes:
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...embedding.html >.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.