1
$\begingroup$

I want to open a file which is packed into the Blend-file with the open() function while the game is running.

Is it possible? And can I write files into it? Like open("Test.blend/Text.txt", "w") or something?.

$\endgroup$
2

2 Answers 2

1
$\begingroup$

If you run the game by pressing P in Blender, you can simply use the bpy module and access Blender's data while the game is running.

If you don't want to depend on Blender, you're limited to the LibLoad function. However, this doesn't support text datablocks. Writing to blend files is also not possible in that case. IMO it'll be much easier to read and write directly to files on the filesystem, rather than packing them inside blend files.

$\endgroup$
8
  • $\begingroup$ Sure but it also has to work with the standalone player. And generally its a bad idea to use bpy within the game engine $\endgroup$
    – Frostie
    Feb 16, 2018 at 20:51
  • $\begingroup$ That's rather situation dependent. I chose the BGE for my project because it allows me to use the bpy module. If this was a requirement, you could have mentioned it in the question. $\endgroup$
    – dr. Sybren
    Feb 16, 2018 at 22:18
  • 1
    $\begingroup$ If with "generally" you mean "if you want your game to run in the standalone player" you're correct, but I would hardly call that "generally". The BGE is also used for simulations, where recording the result of the physics engine and/or simulation data to Blender's FCurves is very powerful. Also I'm a former BGE developer, I kind of know what I'm talking about ;-) $\endgroup$
    – dr. Sybren
    Feb 17, 2018 at 13:34
  • 1
    $\begingroup$ Please mark this answer as 'Accepted', or let me know in which way it's not good enough. $\endgroup$
    – dr. Sybren
    Mar 4, 2018 at 21:38
  • 1
    $\begingroup$ What you want is not possible, as I point out in my answer. $\endgroup$
    – dr. Sybren
    Mar 5, 2018 at 16:47
1
$\begingroup$

Bpy module and functions do not work in standalone player mode. suggest using write()or open() methods.

$\endgroup$

You must log in to answer this question.

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