Development Console

Based on ideasman42’s New BGE Interactive Console, this console allows for quick debug via an interactive console.

Last tested with blender 2.62

Integrating this console into your current project is simple, copy a font to your working directory, create a DevCon() object and call the it’s main() every frame e.g:

import bge

from console_ import Console
    
def init(cont):
    own = cont.owner
    own['console'] = Console(bge.logic.expandPath("//phaisarn.ttf"), toggle_key=bge.events.ACCENTGRAVEKEY)
    cont.script = 'main.main'
    
def main(cont):
    own = cont.owner
    own['console'].main()

An example can be found here, open it up and hit the tilde/accent/grave key (the one under ESC). Try “bge.logic.getCurrentScene().objects[‘cube’].position.x += 1”. The console can access all the bge api and all your game data.

The code can be found in the example.

Attachments


Interessting

Does that mean the code you execute with the console is bound to the controller starting the console or is it an independent thread?

I don’t quite understand what you are asking, essentially this is a python console within the bge.

Whoa.

Just

Whoa