diff options
author | Mitchell Stokes <mogurijin@gmail.com> | 2010-08-28 06:07:55 +0400 |
---|---|---|
committer | Mitchell Stokes <mogurijin@gmail.com> | 2010-08-28 06:07:55 +0400 |
commit | 5c23537daa5c669b672528b0ed2bcaef2038f766 (patch) | |
tree | d8dafae80815cdd6d05e23ededc87df0098b2eb3 /source/gameengine/PyDoc | |
parent | 5729b991fa06734a7a7d58b4ff0f2feab5db8bca (diff) |
Committing patch [#23278] (by me)
This patch allows a user to pass binary data to LibLoad() to load a blend file from memory instead of a file path. I don't know how useful this will be for others, but I've used it so far for:
* Decrypting .blend files and loading them without having to store the .blend on the hard drive
* Pulling .blend data out of an archive and loading it (again skipping the hard drive)
So, it seems the biggest use for this is skipping a bit of file IO (and possibly some security problems).
Example usage:
import bge
with f as open('myfile.blend', 'rb'):
data = f.read()
bge.logic.LibLoad('Name', 'Scene', data)
Diffstat (limited to 'source/gameengine/PyDoc')
-rw-r--r-- | source/gameengine/PyDoc/bge.logic.rst | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/source/gameengine/PyDoc/bge.logic.rst b/source/gameengine/PyDoc/bge.logic.rst index a10733569f3..a7eb5635d0f 100644 --- a/source/gameengine/PyDoc/bge.logic.rst +++ b/source/gameengine/PyDoc/bge.logic.rst @@ -173,14 +173,16 @@ General functions Restarts the current game by reloading the .blend file (the last saved version, not what is currently running). -.. function:: LibLoad(blend, type) +.. function:: LibLoad(blend, type, data) Converts the all of the datablocks of the given type from the given blend. - :arg blend: The path to the blend file + :arg blend: The path to the blend file (or the name to use for the library if data is supplied) :type blend: string :arg type: The datablock type (currently only "Scene" and "Mesh" are supported) :type type: string + :arg data: Binary data from a blend file (optional) + :type data: bytes .. function:: LibNew(name, type, data) |