I am having trouble just starting a script in BGE for example

cont = GameLogic.getCurrentController()
print dir(GameLogic)

This does not print out in a console window - In fact I get no interaction with the console window at all At this point I would love to simply print something out from a script to the console. Is there a quick test to check my system? Is there a tutorial which just gets things rolling? Thanks in advance

  • $\begingroup$ Are you trying to use the external Command Prompt style one, or the one in Blender? $\endgroup$ – VRM Apr 15 '15 at 17:29
  • $\begingroup$ Usually the one in blender _ I have tried this on a windows machine and on my linux machine in both cases hoping that the "command Prompt" or "terminal window" would be the console which was accessed in stead of the one in blender which to me seems like where I should look. $\endgroup$ – DPR-treasureIsland Apr 16 '15 at 19:57
  • 1
    $\begingroup$ someone please give this question a more meaningful Title. $\endgroup$ – zeffii Apr 17 '15 at 5:46

You need to import GameLogic before you can use it, print statement has been replaced by a function in python3 print( arg ).

This works:

import bge
import GameLogic
cont = GameLogic.getCurrentController()

or alternatively

cont = bge.logic.getCurrentController() # bge.logic is automatically imported

Note that the script wouldn't work in the python console (Editor Type) only when wired in the logic editor.

enter image description here

The output goes to console opened via main menu: Window / Toggle System Console


  • $\begingroup$ Thanks for the reply, there is still something very very simple/basic I am not doing. when I paste that into the script editor and press run script it does not talk to the console..? Alternately when I try using an "always sensor" wired to a "python controller" with the new text.py created from the above - in both cases it hangs (highlights in red?) on the import bge line.... $\endgroup$ – DPR-treasureIsland Apr 16 '15 at 19:55
  • $\begingroup$ basically if I try running the stand alone player (pushing the standalone player button) the results are similarly uninspiring. I have tried this with both the "this works" and the "alternatively" - is there a set up that I am missing or again a layout for the intellectually challenged that I might access? Thanks $\endgroup$ – DPR-treasureIsland Apr 16 '15 at 19:55
  • $\begingroup$ With console I mean from the main menu: Window / Toggle System Console. $\endgroup$ – stacker Apr 16 '15 at 20:01
  • 1
    $\begingroup$ @DPR-treasureIsland I tried to clearify this in the post did it help? $\endgroup$ – stacker Apr 16 '15 at 20:16

This is a bit late but anyway:

It might be that your script is running on a different layer in Blender, and therefore not printing out in the console. Even if an always actuator is connected to that script, your script must somehow be able to run in the current layer in Blender.

So what you should do is try running a print command on an object of the current layer you are on. Hope that helps.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.