Page 1 of 1
Posted: Thu Oct 16, 2008 6:43 pm
It looks like a long time ago (the era of 1.10.x) there was a way to write plugins in Python. I wish this was possible now, as I have some ideas for plugins and I don't know C++ (nor do I have any desire to learn C++ in the near future). Python is, for many programs, a wonderful language for writing plugins (Blender, GIMP, etc.) and I think a lot more people (at least me) would make plugins for BZFlag if they could in Python. (p.s. I think this is in the wrong forum. If it is, please move it)
Posted: Thu Oct 16, 2008 7:45 pm
Posted: Thu Oct 16, 2008 11:39 pm
So, nobody is working on it anymore? That is a shame.
Posted: Fri Oct 17, 2008 4:39 am
The API didn't exist untill 2.0.x.
The python plug-in is a fair amount of work to keep up to date, but it's mostly trivial work (just making mappings).
I don't think there is a lot of interest because the amount of C++ needed to make plug-ins is pretty simple. and python is very similar to C++ anyway so the leap to making them in C++ is not hard at all. This means there isn't much of a call for it, so no developers really have a need to keep it up to date.
Posted: Fri Oct 17, 2008 6:32 am
The Boost.Python library makes it easier to expose C++ libraries to python. I was going to try to expose the bzfsAPI, but the Boost.Python library generally requires the Boost build tools. I can use Boost.Build, but I am unfamiliar with configure and couldn't find out how to link to the plug-in API.
From the Boost website:
The Boost Python Library is a framework for interfacing Python and C++. It allows you to quickly and seamlessly expose C++ classes functions and objects to Python, and vice-versa, using no special tools -- just your C++ compiler. It is designed to wrap C++ interfaces non-intrusively, so that you should not have to change the C++ code at all in order to wrap it, making Boost.Python ideal for exposing 3rd-party libraries to Python. The library's use of advanced metaprogramming techniques simplifies its syntax for users, so that wrapping code takes on the look of a kind of declarative interface definition language (IDL).
Following C/C++ tradition, let's start with the "hello, world". A C++ Function:
char const* greet()
return "hello, world";
can be exposed to Python by writing a Boost.Python wrapper:
using namespace boost::python;
That's it. We're done. We can now build this as a shared library. The resulting DLL is now visible to Python. Here's a sample Python session:
>>> import hello_ext
>>> print hello.greet()