As I already searched through, there are some complications with bge for me, too. I am trying to program a crude chat system and add a loop that breaks once I click the left mouse button.

However, as soon as I add this if-clause and define the mouse controller, it fails running the script.

import bge bge.logic.getCurrentController() Maus=bge.events.LEFTMOUSE name=input("Willkommen. Namen eingeben und mit Eingabetaste bestätigen. "); print("Hallo, ich bin %s." % name); print("Mit linker Maustaste beenden."); while 1: input("<%s> " % name); if Maus==true:break;

(Modified the code after some minor updates)
The console says that the module bge could not be found. As I have no objects in my blender file yet, because I just want to script a chat that is working without any dependency on objects, I am quite helpless.

I am kind of new to python scripting and I did my best but maybe there is an error in the code somewhere. I hope someone can help me.

  • $\begingroup$ The bge module is part of the game engine, it is only available while the game engine is running. See this answer. $\endgroup$
    – sambler
    May 27, 2017 at 3:05
  • $\begingroup$ Okay, I see that it does not work with the console. I still do not know what to do to make it work? Do I have to go into an other window and start with P or what exactly is needed to be done? Sorry if I don't get it but I cannot find a solution out of the answer you gave there either. (Explaination for noobs or so) $\endgroup$ May 27, 2017 at 12:50
  • $\begingroup$ Operators are used within blender to perform tasks, for example bpy.ops.object.delete() will delete the selected objects, they are run each time you choose a menu item or use a shortcut key. Start with the addon tutorial to see how an operator works. A modal operator is one that allows you to respond to events while it is running, follow the link for an example. $\endgroup$
    – sambler
    May 28, 2017 at 6:13


You must log in to answer this question.

Browse other questions tagged .