Mock BGE Python API for Autocomplete

One of the most used features on all IDEs is autocomplete. VS has it, Sublime has it, and game engines like Unity or Unreal come with it. Not blender. Until now!

This is running on Windows 7, with the autocomplete-python extension configured as such:
Python Executable Paths: …\Blender\2.78\python\bin\python.exe
Extra Paths for packges: api
(Autocomplete-Plus) Keymap for confirming a suggestion: tab always

I plan to bundle this editor with UPBGE and Community Addon, and distribute it all together so that we can get a modern game engine experience with blender.

For it to work, you need the this API folder (containg all the fake Python definitions):

It is not limited to Atom however, any text editor you have that supports autocomplete for Python is most likely capable of using the API files to integrate the BGE API with it.

Notice that, for now, this fake API has been made manually, but I will probably develop a parser for some of the outputs of sphinx (the blender automatic documentation generator tool) that builds the fake API.

EDIT: Now a ready-to-use build can be found here

Here you are (blender 2.78a api): (86.6 KB)

Hi, this sounds very useful.
However… I’ve got a set of api entries which I use with pycharm. The problem is that it doesn’t really understand them. So it highlights every use of mathutils.Vector as being slightly wrong because it doesn’t know what argument it should take.

Do your files correct this issue?

Mine would solve the issue since it comes with the init for every class, it also returns the actual type for functions that requiere it (like addObject returns a KX_GameObject) and even moks the behaviour of CListValue so that you can get a KX_GameObject (mock object) from doing KX_Scene.objects[“AnythingHere”].

EDIT: The only thing, for now, that I found not possible, is to recognize specific Actuators/Controllers/Sensors/Objects that are created by recasting a type in the GE. For example if you do obj.actuator[1] it will return a SCA_IActuator (maybe it should return Actuator?), instead of, for example a SoundActuator. This is something with hard if any solution, since without actually running the GE we can’t know of wich type a specific actuator is since it doesn’t even exists yet. This is not a problem for me, since I don’t use logic bricks, but maybe someone else will find it more anoying.

However if you compare it with the one posted by @alabd14313 (wich doesn’t), mine is much more incomplete and lacks actual documentation, it only has the definitions. I have not tested it, but does this API work like in the example image? It feels like in such case it should not know what scene.objects[“some”] is.

This will be solved (the incompleteness&docs) the day I dicide the make a script to automate the proccess, but since this is the first try it was made manually and I can not add alll entries, it’s too much work.

Ah cool. Very useful.

I’ll add UPBGE API soon.
You can use Spyder IDE for python to use help comments. There is a bug in this IDE that will be solved in version 3.2.
If you want freedom, don’t use proprietary IDEs.

Here is UPBGE API : (87.8 KB)
You can use Spyder IDE with codecompletion and help comments (there is a bug in IDE that will be solved in v3.2).

Could you please show an image of what happens when you do “bge.logic.getCurrentScene().objects[“Any”].” with the APIs you provide?

OK, I’ve made the scrapper after all. I also boundled it all for ease of use. Here:

Download scrapper (To run with Python): (197 KB)


As I make the API, I got somme errors … some “unknow types” in page’s builds and a traceback error where it should be : “Test BGE : OK”
An idea from where it could come from ?

can this be used in pycharm?