Hiding files in a Blender Game

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.

• 'No game designer wants that.' Untrue. – someonewithpc Nov 3 '16 at 21:18
• 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. – 10 Replies Nov 28 '16 at 11:27

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.

• It isn't going to pack files that are only mentioned in scripts – revengeofthemadmadman Jul 30 '16 at 17:58
• 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. – Billy S Jul 30 '16 at 18:32
• 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. – revengeofthemadmadman Jul 30 '16 at 18:37

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.

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: