Python: reading internal file instead of external via script?

Hey! This probably is quite simple thing, but I thought to ask. Instead of opening a external file,
how could I open a internal .txt file (which is written within blend file).

…mindfart

I’m not sure if it’s possible in the BGE by default. It might require Blender Python modules to do. But it kind of wouldn’t usually be done as the text editor is usually used to write scripts, not text files. Are you sure that you need to open an internal text file?

I just wished to “hide” map txt data inside the game file just like the rest of the python script.
I could ofcourse just do them as variables (same result), but the original idea was to use plain text data.

For security, you could also save the text data as an external binary file, or a text file with a different format. You could also pickle it, which would make it uneditable (unless you de-pickle-ized it first).

I can’t restore with pickle but I can dump with it. I don’t know why.

class bge.types.SCA_PythonController(SCA_IController)

:wink: