The latest version of the ScriptENGINE 2010: 3D Engine is now available.
Download it now! No obligations or time limitations. Purchase a license at any time to activate the full version.

The ScriptENGINE Managed Filesystem

ScriptENGINE: Lua 3D Engine Article SeriesIn this article, we'll take a look at the ScriptENGINE Managed Filesystem to keep track of your application resources.

The managed filesystem is used when specifying file names in your scripts. It searches your managed folders/zips for the requested file. Resource management is easier because you can move your resources around without having to updates all your scripts with new filename locations.

 

View the Demo Code

The demos are included with the ScriptENGINE SDK. Navigate to the ScriptENGINE SDK/[File System] The managed file system folder for the example.

Open the world.e76script in the SciTE code editor. We will be referring to the world.e76script for the rest of this article.

 

The ScriptENGINE SDK

Now's a great time to get the ScriptENGINE SDK (including the SciTE code editor, Programmer's Reference and ScriptENGINE Demos).

 

The ScriptENGINE Demo Framework

The ScriptENGINE Demos are run using the runDemo.e76script framework code in the ScriptENGINE SDK/Demos folder.

 

Adding Folders to the Managed Filesystem

Call the IApp:addSearchPath() function to add a folder to the ScriptENGINE managed filesystem. The ScriptENGINE will search this folder (and possibly its sub-folders) for any requested files used by its engines.

 

Adding Zip-Files to the Managed Filesystem

Call the IApp:addSearchZip() or the IApp:addSearchZipDecompressed() functions to add zip-files to the ScriptENGINE managed filesystem. The ScriptENGINE will search this zip-file for any requested files used by its engines.

 

Clearing the Managed Filesystem

Use the IApp:clearSearchPaths() function to remove search folders/zips from the managed filesystem.

 

Accessing the Managed Filesystem

Use the IApp:getFilenameFromFileSystem() or IApp:getFilenameListFromFileSystem() functions to manually search the managed filesystem.

Search the filesystem for all files matching a specific filename mask:

filenames = IApp:getFilenameListFromFileSystem('*.e76*')

The '*.e76*' filename mask can include wildcards. The filenames are returned as a Lua table (if found), otherwise nil is returned.


The ScriptENGINE Programmer's Reference

We recommend reading the IApp Interface in the Programmer's Reference for more info about the Managed Filesystem.