Python plugins

Questions, comments, and news on the server side plug-ins and it's API
Post Reply
User avatar
clarahobbs
Private First Class
Private First Class
Posts: 272
Joined: Thu Jan 10, 2008 1:45 am
Location: The Fourth Dimension

Python plugins

Post by clarahobbs »

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)
FKA Ratfink
User avatar
joevano
General
General
Posts: 1863
Joined: Sat Jun 18, 2005 1:08 pm
Location: South Bend, Indiana, USA

Post by joevano »

There is nothing worse than aggressive stupidity. -- Johann Wolfgang von Goethe
"How many legs does a dog have if you call his tail a leg? Four. Calling a tail a leg doesn't make it a leg." -- Abraham Lincoln
User avatar
clarahobbs
Private First Class
Private First Class
Posts: 272
Joined: Thu Jan 10, 2008 1:45 am
Location: The Fourth Dimension

Post by clarahobbs »

So, nobody is working on it anymore? That is a shame.
FKA Ratfink
User avatar
JeffM
Staff Sergeant
Staff Sergeant
Posts: 5196
Joined: Fri Dec 13, 2002 4:11 am

Post by JeffM »

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.
ImageJeffM
Enigma
Private First Class
Private First Class
Posts: 212
Joined: Sat Apr 23, 2005 3:13 am

Post by Enigma »

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:

QuickStart

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).

Hello World

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:

#include <boost/python.hpp>

BOOST_PYTHON_MODULE(hello_ext)
{
using namespace boost::python;
def("greet", greet);
}
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()
hello, world
Post Reply