0
$\begingroup$

This is for my own self education and understanding. I tried to open some blend files in a text editor just to see what's in there, and it was mostly unreadable. How can I see the individual modules, and where they are located or run from?

@Ray When you add a sensor and an actuator and connect them and make something happen, like move a cube. How can I look "under the hood" and see the script that makes that go?

$\endgroup$
  • $\begingroup$ What do you mean by 'modules' and is this related to the 'game-engine' tag? $\endgroup$ – Ray Mairlot Feb 23 '17 at 18:38
1
$\begingroup$

The majority of the game engine is not Python. It is written in C, and as a result it is compiled into the engine and cannot be viewed as 'python.'

I'm guessing you're looking at the Geodesic Chess blends, in which case nearly all of the scripts are in the Scripts folder rather than inside the blend. The non-script modules include:

  • bge (built into Blender Game Engine)
  • mathutils (built into Blender and Blender Game Engine)
  • os (built into python, for accessing files)
  • json (built into python, converts python dictionaries into nicely formatted text files)

Documentation for them can be found by clicking on the links above. You may also want to look at Reading the BGE API.


As for the unreadability of blend files, this is because it is stored as binary data, which cannot be read as text (well it can, but as you have discovered, it is meaningless).

$\endgroup$
1
$\begingroup$

I tried to open some blend files in a text editor just to see what's in there, and it was mostly unreadable.

A blend file is just a bunch of configuration. It can contain custom Python code. It will never ever contain Things that are in Blender already. See the .blend file as configuration to setup Blender (or the Blenderplayer).

How can I see the individual modules, and where they are located or run from?

You will not. As in sdfgeoff's answer Blender and the Blenderplayer are native code. They offer a Python binding (API) to certain internal aspects. You need to read the API documentation for details.

How can I look "under the hood" and see the script that makes that go?

When your script does not "makes that go" you typically get errors that you can see in the console window (at WinOs you can toggle it via Menu/Windows/Toggle System Console). When you are unsure that your code behaves as you think it should behave (e.g. because you do not see an effect, or you want to learn), then add print statements into your code and see the result in the console window. When there is no output you know that your print statement was never executed.

print("print() was executed")

or

name = "James Bond"
print("name was set to", name)

Be careful with print statements that you easily identify them. Typically you want to remove them before going productive. Seeing a lot of print statements is confusing too.

$\endgroup$

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.