Embedding as scripting engine

Úlfur Kristjánsson theincredibleulk at hotmail.com
Tue Jul 8 12:50:55 CEST 2003


Python... a great language, no doubt. And the abillity to be able to
extend it with C/C++ code, fantastic. But has anybody been able to
successfully embed Python in their application to use it as a
scripting language of sorts?

I am in the process of writing a game and from the documentation and
word of mouth gathered that Python would be just the thing for the
scripting part. And sure enough it is easy enough to run Python code
from C/C++. However, in order to be make it do something actually
useful for my game it would be handy to be able to pass in anything
besides the basic data types (strings, numerics) such as either an
instance of or a pointer to a gameobject. What I want to be able to do
is something like this:

GameObject go;

Py_Initialize()
...
PyObject* po = GameObject2PyObject(go);
...
result = PyObject_CallObject(func, "O", po );
...
go = PyObject2GameObject(result);

Theres alot of documentation and discussion out there that suggests
that this should be possible but noone seems to tell you how it's
actually done. Am I just missing something blatantly obvious?

Thanks
//ulk




More information about the Python-list mailing list