Running Game Engine from Command Line

Hello,

I apologize if another newbie has asked this already, but I was wondering if it’s possible to run the Game Engine from the command line using bge.logic.startGame()

I attempted to do ./blender -P script.py,

where script.py is as follows:

import bge
bge.logic.startGame()

Of course, this does not work as bge is only available whilst the game engine is running.

Any suggestions?

Thanks!

If you want to start a BGE game from the command line, use the BlenderPlayer. If you want to start a BGE game as soon as you open the blend file via Blender, the only real way is to set it to Auto-start from the game menu. Note, though, that doing this causes the blend to immediately start the game engine, so your game will be in a lock if you save it after turning Auto-start on.

Actually, You could call the operator to launch the game engine using a script.
Import the bpy module and somewhere there will be an operator.

Yes, it seems you cannot call that operator from the commandline, as there is no context to work from. Your best bet would be enabling autostart, or using BlenderPlayer