File Structure

From OrbEdit Wiki

Jump to: navigation, search

Directory Basics

Your Orb installation directory contains a single directory named Data, in which all of Orb's game files exist. The Data directory has the following sub-directories:

Image:FolderOpen.png Data: Root directory for Orb
Image:FolderOpen.png Core: Core files of Orb and OrbEdit. See Hacking OrbEdit for more information
Image:FolderClosed.png Editor: All scripts and resources used by OrbEdit
Image:FolderClosed.png Scripts: Core Orb scripts responsible for coroutines, animation, text, input, etc. Orb's true power lies within, modify freely!
Image:FolderClosed.png Templates: Default files used in various places
Image:FolderClosed.png Fonts: Font files (.ttf) for displaying text within Orb
Image:FolderOpen.png Projects: Parent project directory for your Orb games
Image:FolderOpen.png <Your Game>: Root directory for your game
Image:FolderClosed.png Images: Image files used by your game
Image:FolderClosed.png Imports: Import files used by your game
Image:FolderClosed.png Levels: Level files for your game
Image:FolderClosed.png Registries: Registry files for your game
Image:FolderClosed.png Scripts: Your game's scripts, organized into various sub-directories
Image:FolderClosed.png Sounds: Sound files for your game
Image:FolderClosed.png XSL: XML Stylesheets for your game
Image:FolderOpen.png Shaders: Uncompiled GLSL vertex and fragment shader files
Image:FolderClosed.png Images: Image files used by Shaders for noise generation, texturing
Image:FolderClosed.png XSL: XML Stylesheets for Orb

In general, you should only ever have to deal with those directories marked with the dashed lines; they are the default directories which make up your game. These directories are copied from Data/Core/Templates/NewProject when you create a new Project via OrbEdit. You are free to organize your game's directories in any way you choose but it is recommended you adhere to the defaults.

Several of the directories in the diagram have sub-directories not mentioned here, they are covered in more detail in the Hacking OrbEdit section.


Root vs Relative Paths

Orb uses a Unix-like notation to access its files. The Data directory is Orb's root directory, and like the root directory on Unix, is referenced with a preceding '/' character.

Likewise, your game has its own root directory, which in the above diagram is the Image:FolderOpen.png <Your Game> directory. This is always the current working directory whenever your game is running. All file names that do not start with the '/' character are assumed to be local to this directory.

An example script to access a file in Orb's root path:

-- Reload all of Orb's default scripts by executing Init.lua again
-- Note that the path to Init.lua begins with "/" since it is located in Orb's root directory
dofile_s("/Core/Scripts/Init.lua");


An example script to access a file in your game's root path:

-- Create a new Sprite
local mySprite = Sprite:new();
 
-- Set the new Sprite's texture to a file in your game's Images directory
-- Note that the file name is relative to your game's root directory
mySprite:setTexture("Images/Tree.bmp");

Orb offers several functions to help you manipulate file names:

  • orb.getRootDirectory(): Returns the fully-qualified path of Orb's Data directory, for example, C:\Program Files\Orb\Data
  • orb.getCurrentDirectory(): Returns the fully-qualified path of your current working directory, for example, C:\Program Files\Orb\Data\Projects\OrbGame
  • orb.resolve(filename): Returns a fully-qualified version of the file name filename. filename can either be relative to Orb's root directory (that is, begin with the '/' character) or be relative to the current directory. All Orb functions that deal with file names use this function, make sure that your functions do as well.


Directory Compression

When you deploy your game from OrbEdit, you are given the option to compress your game's directory structure into a single file. Orb can read your resource files from this compressed directory the same way it can read them from a normal directory. There are several advantages of compressing your directory:

  • Smaller game size: Compression will make your game easier to distribute, since the overall size is smaller
  • Harder to cheat: Since your game's files will not be right out in the open, cheating is much less straight-forward. While it is still possible to access your game's core files by decompressing this directory, it's an added step that makes it that much more difficult. See Preventing Cheating for more information.
Personal tools