3
$\begingroup$

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

$\endgroup$
3
  • $\begingroup$ Are you trying to use the external Command Prompt style one, or the one in Blender? $\endgroup$
    – J Sargent
    Commented Apr 15, 2015 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$ Commented Apr 16, 2015 at 19:57
  • 1
    $\begingroup$ someone please give this question a more meaningful Title. $\endgroup$
    – zeffii
    Commented Apr 17, 2015 at 5:46

2 Answers 2

4
$\begingroup$

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()
print(dir(cont))

or alternatively

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

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

Related:

$\endgroup$
4
  • $\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$ Commented Apr 16, 2015 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$ Commented Apr 16, 2015 at 19:55
  • $\begingroup$ With console I mean from the main menu: Window / Toggle System Console. $\endgroup$
    – stacker
    Commented Apr 16, 2015 at 20:01
  • 1
    $\begingroup$ @DPR-treasureIsland I tried to clearify this in the post did it help? $\endgroup$
    – stacker
    Commented Apr 16, 2015 at 20:16
0
$\begingroup$

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.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .