Capricorn 76
ScriptENGINE supports a managed filesystem which keeps track of your application resources and where they are.
This makes it simple to specify file names in your scripts since you don't need to use full paths.
ScriptENGINE will search its filesystem for a file name matching your file mask.

All the ScriptENGINE interfaces use the managed filesystem.
But the filesystem also provides some functions for you to directly use.

---------------------------
---------------------------
-- Filesystem example
-- Copyright (c)2007-09 Capricorn 76 Pty. Ltd.
--
-- ScriptENGINE supports a managed filesystem which keeps track of your application resources and where they are.
-- This makes it simple to specify file names in your scripts since you don't need to use full paths.
-- ScriptENGINE will search its filesystem for a file name matching your file mask.
--
-- All the ScriptENGINE interfaces use the managed filesystem.
-- But the filesystem also provides some functions for you to directly use.
--
-- NOTE:
-- The ./Demos/runDemo.e76script is a utility script used to run all the examples.
-- It loads the world, calls the OnWorldLoad(), OnWorldUnload() functions, and runs the graphics engine loop, waiting for the user to press escape.
---------------------------
---------------------------

---------------------------
-- runDemo.e76script calls this function when the world is loaded
---------------------------
function OnWorldLoad(worldName)
    --print('OnWorldLoad');

    OnWorldLoadGui();

    ---------------------------
    -- The SDK world editor creates a worldIds.e76script when the world is saved. It contains all the entity ids.
    -- We load the IDs so that we can refer to the world entities using friendly names.
    ---------------------------
    IApp:loadScript(IWorld:getNameLong() .. '/worldIds');
    IWorld:setActiveCameraId(idCamera_cam1);
end

---------------------------
-- Load the example's specific gui
---------------------------
function OnWorldLoadGui()
    IGraphics:loadGui('help');

    ---------------------------
    -- We can iterate over the entire filesystem searching for all files that match a mask
    -- It returns a table of filenames.
    -- Note that the results are based on the priority of folders as they were added via the IApp:addSearchPath()
    ---------------------------
    filenames = IApp:getFilenameListFromFileSystem('*.e76*');

    ---------------------------
    -- We fill a listbox with all the filenames,
    -- but the Gui Controls example shows how the
    -- DirList control can do this for us automatically
    ---------------------------
    for i = 1,table.getn(filenames) do
        IGraphics:addListboxItem('list', filenames[i]);
    end
end

---------------------------
-- runDemo.e76script calls this function when the world is unloaded
---------------------------
function OnWorldUnload(worldName)
    --print('OnWorldUnload');
end

Copyright © 2006-23 Sep 2009 Capricorn 76 Pty. Ltd. (created on Wed Sep 23 16:49:12 2009)