473,385 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

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
1 1713
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rajorshi | last post by:
Hi, I have two classes, say, Base1 and Base2. Now Derv is a class derived from both like class Derv(Base1,Base2)..... In the destructor of the derived class, if I write something like this def...
1
by: Pierre Maricq | last post by:
Hi, I am using Win2000 and Access2000. I need to build build a macro or write a VBA in Access that would screen all files contained in a directory on my C drive (files are structrured DAT...
4
by: Gibby Koldenhof | last post by:
Hiya, I'm setting up some code in the spirit of Design Patterns, OOP, etc. All nice and well, it handles pretty much all OO style things and serves my purposes well. There's one last final...
15
by: Bryan | last post by:
I have a multi-threaded C# console application that uses WMI (System.Management namespace) to make RPC calls to several servers (600+ ) and returns ScheduledJobs. The section of my code that...
5
by: mike | last post by:
If I have a document like: <script> function mike_test() {alert('hi');} </script> <iframe src="blank.html" id="my_iframe1"> </iframe> and in blank.html I have:
4
by: ronchese | last post by:
Hello! I have a UserControl that have two other controls inside it. I need to set a different border color for my UserControl when the mouse enters it, and restore the border color when the...
1
by: Alan | last post by:
Dear All, I'm currently trying to write a C program that has to call functions that are contained inside a dll. Could somebody possibly talk me through how I can integrate and use a dll in...
0
by: sunfire | last post by:
I have a navigation menu contained in a LoginView.LoggedInTemplate on a master page. The navigation menu has 1 node at this point called News. What I want to do is be able to access the Text...
1
by: Memphis Steve | last post by:
Is it possible to combine multiple javascipts into one file and then call that file from a linked URL in the head section of an XHTML file? Here are the two scripts I want to use with the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.