---------------------------
---------------------------
-- Quake example
-- Copyright (c) 2007-09 Capricorn 76 Pty. Ltd.
--
--
-- 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 before the world is loaded
---------------------------
function OnWorldPreload(worldName)
--print('OnWorldPreload:', worldName);
-- This demo needs to add more data to the engine's managed filesystem, so resources will be found as required.
-- The 'quakeExampleAddedSearchPath' global variable helps us add the search path to the engine once.
-- Alternatively, we could call IApp:addSearch...() in the OnWorldLoad() & IApp:clearSearchPaths() in the OnWorldUnload()
if (not(quakeExampleAddedSearchPath)) then
quakeExampleAddedSearchPath = true; -- Global variable is now defined
-- Three different options are displayed here:
-- using a zip directly
-- unzipping a zipfile to a cache folder, and then referencing the unzipped folder
-- using a folder directly
-- Use a unique number for path priority, so we can remove this search path later.
-- The path priority also controls how the engine searches its managed filesystem with relation to the other paths/zips.
IApp:addSearchZip(worldName .. '/map-20kdm2.zip', false, 100);
-- Alternatively, you can have the engine unzip the file immediately, place it in a cache and reference that cache instead of the zip-file.
-- The cache is automatically removed when the program exits
--IApp:addSearchZipDecompressed(IWorld:getNameLong() .. '/map-20kdm2.zip', false, 100);
-- Alternatively, you can manually unzip the zip-file and add the unzipped folders to the managed filesystem
--IApp:addSearchPath(IWorld:getNameLong() .. '/map-20kdm2', false, 100);
end
end
---------------------------
-- runDemo.e76script calls this function when the world is loaded
---------------------------
function OnWorldLoad(worldName)
--print('OnWorldLoad:', worldName);
-- Load the demo's GUI
IGraphics:loadGui('help');
-- Allow the user to move the FPS camera around.
-- This camera's properties were set in the 3D World Editor
IWorld:setActiveCameraAutoProcessed(true);
end
---------------------------
-- runDemo.e76script calls this function when the world is unloaded
---------------------------
function OnWorldUnload(worldName)
--print('OnWorldUnload:', worldName);
--This will remove the search path from the engine's managed filesystem.
-- If his is called, then the IApp:addSearch...() must be called again in the next OnWorldLoad() if this world is reloaded...
--IApp:clearSearchPaths(100);
end
Copyright © 2006-23 Sep 2009 Capricorn 76 Pty. Ltd. (created on Wed Sep 23 16:49:12 2009)