0
$\begingroup$

I'm making a video game using Blender's Game Engine, making a lot of progress and learning a lot as I go. Pretty much all data for a game gets packed into the ".exe" for the game when you export it automatically, however I have some scripts that I've written that need to access files externally on my harddrive and I haven't figured out a way to freely "pack" these files into .Blend/.Exe.

I want to be able to just drop a bunch of files inside of my game without doing something as messy as making up logic nodes that don't do anything that are just bound to some of these files so that they get copied in. Is there a way to just put things into my Blend project freely like it's its own harddrive?

As it is right now, I have a bunch of assets that sit outside of the game's .exe and anybody with the game could just freely snoop through some of these textures. No game designer wants that.

$\endgroup$
2
  • 4
    $\begingroup$ 'No game designer wants that.' Untrue. $\endgroup$ Commented Nov 3, 2016 at 21:18
  • 4
    $\begingroup$ I quite like it when I am able to download a zip with the .exe and texture files both floating around. I find it fun to swap out textures for dank memes. It adds a whole new level of customizability. $\endgroup$
    – 10 Replies
    Commented Nov 28, 2016 at 11:27

3 Answers 3

0
$\begingroup$

Open blender, and select File > External Data > Pack All Into .blend. This should pack all your game assets that are in use into the .blend. Then, when you save it as a .exe, they should be in the .exe.

$\endgroup$
3
  • $\begingroup$ It isn't going to pack files that are only mentioned in scripts $\endgroup$ Commented Jul 30, 2016 at 17:58
  • 1
    $\begingroup$ I see. Well, one thing you could do is to create a object, make it invisible, and add those textures to it. I don't know of any regular way to do this. $\endgroup$
    – krypticbit
    Commented Jul 30, 2016 at 18:32
  • $\begingroup$ That was an idea that I had too, that I've already mentioned in my question (how I could do that using Logic Nodes to hold files as well). I think there has to be a way to inject files in manually. $\endgroup$ Commented Jul 30, 2016 at 18:37
0
$\begingroup$

An easy solution is to use pythons zip module to unzip everything into a temporary directory upon request. A harder solution is to make your own filesystem (something like a .wad file) which just joins files together and stores how to seperate them. Then you can load them from the binary data.

To my knowledge no-one has done this for BGE yet, but it shouldn't be too hard to do.

$\endgroup$
0
$\begingroup$

If they are scripts, you could pickle them.

tarfile would also be a suitable method to bundle up a dir of items.

import os
import tarfile

cwd  = os .getcwd()
listing  = os .listdir( cwd )

##  tar files together
with tarfile .open('files.tar', 'w') as tar:
  for name in listing:
    tar .add( name )


##  extract files
with tarfile .open('files.tar') as tar:
  tar .extractall()
$\endgroup$

You must log in to answer this question.

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