Index: code/branches/resource2/data/levels/empty_level.oxw
===================================================================
--- code/branches/resource2/data/levels/empty_level.oxw	(revision 5646)
+++ code/branches/resource2/data/levels/empty_level.oxw	(revision 5654)
@@ -1,10 +1,10 @@
 <?lua
-  include("overlay/stats.oxo")
-  include("overlay/hudtemplates3.oxo")
+  include("stats.oxo")
+  include("hudtemplates3.oxo")
 ?>
 
 <?lua
-  include("levels/templates/spaceship_assff.oxt")
-  include("levels/templates/spaceship_pirate.oxt")
+  include("templates/spaceship_assff.oxt")
+  include("templates/spaceship_pirate.oxt")
 ?>
 
Index: code/branches/resource2/data/levels/gametype_asteroids.oxw
===================================================================
--- code/branches/resource2/data/levels/gametype_asteroids.oxw	(revision 5646)
+++ code/branches/resource2/data/levels/gametype_asteroids.oxw	(revision 5654)
@@ -1,6 +1,6 @@
 <?lua
-  include("overlay/hudtemplates3.oxo")
-  include("overlay/stats.oxo")
-  include("levels/templates/spaceship_assff.oxt")
+  include("hudtemplates3.oxo")
+  include("stats.oxo")
+  include("templates/spaceship_assff.oxt")
 ?>
 
Index: code/branches/resource2/data/levels/gametype_underattack.oxw
===================================================================
--- code/branches/resource2/data/levels/gametype_underattack.oxw	(revision 5646)
+++ code/branches/resource2/data/levels/gametype_underattack.oxw	(revision 5654)
@@ -1,7 +1,7 @@
 <?lua
-  include("overlay/hudtemplates3.oxo")
-  include("overlay/stats.oxo")
-  include("overlay/underattackhud.oxo")
-  include("levels/templates/spaceship_assff.oxt")
+  include("hudtemplates3.oxo")
+  include("stats.oxo")
+  include("underattackhud.oxo")
+  include("templates/spaceship_assff.oxt")
 ?>
 
Index: code/branches/resource2/data/levels/old/CuboidSpaceStation.oxw
===================================================================
--- code/branches/resource2/data/levels/old/CuboidSpaceStation.oxw	(revision 5646)
+++ code/branches/resource2/data/levels/old/CuboidSpaceStation.oxw	(revision 5654)
@@ -1,8 +1,8 @@
 <?lua
-	include("overlay/hudtemplates3.oxo")
+	include("hudtemplates3.oxo")
 ?>
 
 <?lua
-	include("levels/templates/spaceship_assff.oxt")
+	include("templates/spaceship_assff.oxt")
 ?>
 
@@ -20,5 +20,5 @@
 <!-------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
 <?lua
-	dofile("../../media/levels/includes/CuboidSpaceStation.lua")
+	dofile("includes/CuboidSpaceStation.lua")
 ?>
 
Index: code/branches/resource2/data/levels/old/physicstest2.oxw
===================================================================
--- code/branches/resource2/data/levels/old/physicstest2.oxw	(revision 5646)
+++ code/branches/resource2/data/levels/old/physicstest2.oxw	(revision 5654)
@@ -1,7 +1,7 @@
 <?lua
-  include("levels/old/spaceshiptemplates_physics.oxw")
+  include("spaceshiptemplates_physics.oxw")
 ?>
 <?lua
-  include("overlay/hudtemplates3.oxo")
+  include("hudtemplates3.oxo")
 ?>
 
Index: code/branches/resource2/data/levels/old/planettest.oxw
===================================================================
--- code/branches/resource2/data/levels/old/planettest.oxw	(revision 5646)
+++ code/branches/resource2/data/levels/old/planettest.oxw	(revision 5654)
@@ -1,8 +1,8 @@
 <?lua
-  include("overlay/hudtemplates3.oxo")
+  include("hudtemplates3.oxo")
 ?>
 
 <?lua
-  include("levels/templates/spaceship_assff.oxt")
+  include("templates/spaceship_assff.oxt")
 ?>
 
Index: code/branches/resource2/data/levels/old/presentation_physics.oxw
===================================================================
--- code/branches/resource2/data/levels/old/presentation_physics.oxw	(revision 5646)
+++ code/branches/resource2/data/levels/old/presentation_physics.oxw	(revision 5654)
@@ -1,6 +1,6 @@
 <?lua
-  include("overlay/hudtemplates3.oxo")
-  include("overlay/stats.oxo")
-  include("levels/templates/spaceship_assff.oxt")
+  include("hudtemplates3.oxo")
+  include("stats.oxo")
+  include("templates/spaceship_assff.oxt")
   math.randomseed(344)
 ?>
Index: code/branches/resource2/data/levels/old/princessaeryn.oxw
===================================================================
--- code/branches/resource2/data/levels/old/princessaeryn.oxw	(revision 5646)
+++ code/branches/resource2/data/levels/old/princessaeryn.oxw	(revision 5654)
@@ -1,10 +1,10 @@
 <?lua
-  include("overlay/hudtemplates3.oxo")
-  include("overlay/stats.oxo")
-  include("levels/templates/spaceship_assff.oxt")
+  include("hudtemplates3.oxo")
+  include("stats.oxo")
+  include("templates/spaceship_assff.oxt")
 ?>
 
 <?lua
-	dofile("../../media/levels/includes/CuboidSpaceStation.lua")
+	dofile("includes/CuboidSpaceStation.lua")
 ?>
 
Index: code/branches/resource2/data/levels/old/questsystem.oxw
===================================================================
--- code/branches/resource2/data/levels/old/questsystem.oxw	(revision 5646)
+++ code/branches/resource2/data/levels/old/questsystem.oxw	(revision 5654)
@@ -1,6 +1,6 @@
 <?lua
-  include("overlay/hudtemplates3.oxo")
-  include("overlay/stats.oxo")
-  include("levels/templates/spaceship_assff.oxt")
+  include("hudtemplates3.oxo")
+  include("stats.oxo")
+  include("templates/spaceship_assff.oxt")
 ?>
 
Index: code/branches/resource2/data/levels/old/sample4.oxw
===================================================================
--- code/branches/resource2/data/levels/old/sample4.oxw	(revision 5646)
+++ code/branches/resource2/data/levels/old/sample4.oxw	(revision 5654)
@@ -1,8 +1,8 @@
 <?lua
-  include("overlay/hudtemplates3.oxo")
+  include("hudtemplates3.oxo")
 ?>
 
 <?lua
-  include("levels/templates/spaceship_assff.oxt")
+  include("templates/spaceship_assff.oxt")
 ?>
 
Index: code/branches/resource2/data/levels/pickuptest.oxw
===================================================================
--- code/branches/resource2/data/levels/pickuptest.oxw	(revision 5646)
+++ code/branches/resource2/data/levels/pickuptest.oxw	(revision 5654)
@@ -1,6 +1,6 @@
 <?lua
-  include("overlay/hudtemplates3.oxo")
-  include("overlay/stats.oxo")
-  include("levels/templates/spaceship_assff.oxt")
+  include("hudtemplates3.oxo")
+  include("stats.oxo")
+  include("templates/spaceship_assff.oxt")
 ?>
 
Index: code/branches/resource2/data/levels/presentation.oxw
===================================================================
--- code/branches/resource2/data/levels/presentation.oxw	(revision 5646)
+++ code/branches/resource2/data/levels/presentation.oxw	(revision 5654)
@@ -1,6 +1,6 @@
 <?lua
-  include("overlay/hudtemplates3.oxo")
-  include("overlay/stats.oxo")
-  include("levels/templates/spaceship_assff.oxt")
+  include("hudtemplates3.oxo")
+  include("stats.oxo")
+  include("templates/spaceship_assff.oxt")
 ?>
 
Index: code/branches/resource2/data/levels/presentation09.oxw
===================================================================
--- code/branches/resource2/data/levels/presentation09.oxw	(revision 5646)
+++ code/branches/resource2/data/levels/presentation09.oxw	(revision 5654)
@@ -1,7 +1,7 @@
 <?lua
-  include("overlay/hudtemplates3.oxo")
-  include("overlay/stats.oxo")
-  include("levels/templates/spaceship_assff.oxt")
-  include("levels/templates/spaceship_H2.oxt")
+  include("hudtemplates3.oxo")
+  include("stats.oxo")
+  include("templates/spaceship_assff.oxt")
+  include("templates/spaceship_H2.oxt")
 ?>
 
Index: code/branches/resource2/data/levels/presentation09b.oxw
===================================================================
--- code/branches/resource2/data/levels/presentation09b.oxw	(revision 5646)
+++ code/branches/resource2/data/levels/presentation09b.oxw	(revision 5654)
@@ -1,8 +1,8 @@
 <?lua
-  include("overlay/hudtemplates3.oxo")
-  include("overlay/stats.oxo")
-  include("levels/templates/spaceship_assff.oxt")
-  include("levels/templates/spaceship_H2.oxt")
-  include("levels/templates/spaceship_pirate.oxt")
+  include("hudtemplates3.oxo")
+  include("stats.oxo")
+  include("templates/spaceship_assff.oxt")
+  include("templates/spaceship_H2.oxt")
+  include("templates/spaceship_pirate.oxt")
 ?>
 
Index: code/branches/resource2/data/levels/presentation_dm.oxw
===================================================================
--- code/branches/resource2/data/levels/presentation_dm.oxw	(revision 5646)
+++ code/branches/resource2/data/levels/presentation_dm.oxw	(revision 5654)
@@ -1,7 +1,7 @@
 <?lua
-  include("overlay/hudtemplates3.oxo")
-  include("overlay/stats.oxo")
-  include("levels/templates/spaceship_assff.oxt")
-  include("levels/templates/spaceship_H2.oxt")
+  include("hudtemplates3.oxo")
+  include("stats.oxo")
+  include("templates/spaceship_assff.oxt")
+  include("templates/spaceship_H2.oxt")
 ?>
 
Index: code/branches/resource2/data/levels/presentation_pong.oxw
===================================================================
--- code/branches/resource2/data/levels/presentation_pong.oxw	(revision 5646)
+++ code/branches/resource2/data/levels/presentation_pong.oxw	(revision 5654)
@@ -1,6 +1,6 @@
 <?lua
-  include("overlay/hudtemplates3.oxo")
-  include("overlay/stats.oxo")
-  include("overlay/ponghud.oxo")
+  include("hudtemplates3.oxo")
+  include("stats.oxo")
+  include("ponghud.oxo")
 ?>
 
@@ -91,5 +91,5 @@
 
   <?lua
-    dofile("../../media/levels/includes/CuboidSpaceStation.lua")
+    dofile("includes/CuboidSpaceStation.lua")
   ?>
 
Index: code/branches/resource2/data/levels/teambasematchlevel.oxw
===================================================================
--- code/branches/resource2/data/levels/teambasematchlevel.oxw	(revision 5646)
+++ code/branches/resource2/data/levels/teambasematchlevel.oxw	(revision 5654)
@@ -1,8 +1,8 @@
 <?lua
-  include("overlay/hudtemplates3.oxo")
-  include("overlay/stats.oxo")
-  include("overlay/teambasematchhud.oxo")
-  include("levels/templates/spaceship_assff.oxt")
-  include("levels/templates/spaceship_pirate.oxt")
+  include("hudtemplates3.oxo")
+  include("stats.oxo")
+  include("teambasematchhud.oxo")
+  include("templates/spaceship_assff.oxt")
+  include("templates/spaceship_pirate.oxt")
 ?>
 
Index: code/branches/resource2/data/levels/teamdeathmatch.oxw
===================================================================
--- code/branches/resource2/data/levels/teamdeathmatch.oxw	(revision 5646)
+++ code/branches/resource2/data/levels/teamdeathmatch.oxw	(revision 5654)
@@ -1,8 +1,8 @@
 <?lua
-  include("overlay/hudtemplates3.oxo")
-  include("overlay/stats.oxo")
-  include("levels/templates/spaceship_assff.oxt")
-  include("levels/templates/spaceship_H2.oxt")
-  include("levels/templates/spaceship_pirate.oxt")
+  include("hudtemplates3.oxo")
+  include("stats.oxo")
+  include("templates/spaceship_assff.oxt")
+  include("templates/spaceship_H2.oxt")
+  include("templates/spaceship_pirate.oxt")
 ?>
 
Index: code/branches/resource2/data/levels/templates/spaceship_H2.oxt
===================================================================
--- code/branches/resource2/data/levels/templates/spaceship_H2.oxt	(revision 5646)
+++ code/branches/resource2/data/levels/templates/spaceship_H2.oxt	(revision 5654)
@@ -23,5 +23,5 @@
 
 <?lua
-  include("levels/includes/weaponsettings_H2.oxi")
+  include("includes/weaponsettings_H2.oxi")
 ?>
 
Index: code/branches/resource2/data/levels/templates/spaceship_assff.oxt
===================================================================
--- code/branches/resource2/data/levels/templates/spaceship_assff.oxt	(revision 5646)
+++ code/branches/resource2/data/levels/templates/spaceship_assff.oxt	(revision 5654)
@@ -35,5 +35,5 @@
     </collisionShapes>
 <?lua
-  include("levels/includes/weaponsettings3.oxi")
+  include("includes/weaponsettings3.oxi")
 ?>
   </SpaceShip>
Index: code/branches/resource2/data/levels/templates/spaceship_pirate.oxt
===================================================================
--- code/branches/resource2/data/levels/templates/spaceship_pirate.oxt	(revision 5646)
+++ code/branches/resource2/data/levels/templates/spaceship_pirate.oxt	(revision 5654)
@@ -38,5 +38,5 @@
 
 <?lua
-  include("levels/includes/weaponsettings_pirate.oxi")
+  include("includes/weaponsettings_pirate.oxi")
 ?>
   </SpaceShip>
Index: code/branches/resource2/data/levels/tutorial.oxw
===================================================================
--- code/branches/resource2/data/levels/tutorial.oxw	(revision 5646)
+++ code/branches/resource2/data/levels/tutorial.oxw	(revision 5654)
@@ -1,6 +1,6 @@
 <?lua
-  include("overlay/hudtemplates3.oxo")
-  include("overlay/stats.oxo")
-  include("levels/templates/spaceship_assff.oxt")
+  include("hudtemplates3.oxo")
+  include("stats.oxo")
+  include("templates/spaceship_assff.oxt")
 ?>
 
Index: code/branches/resource2/data/levels/waypoints.oxw
===================================================================
--- code/branches/resource2/data/levels/waypoints.oxw	(revision 5646)
+++ code/branches/resource2/data/levels/waypoints.oxw	(revision 5654)
@@ -1,8 +1,8 @@
 <?lua
-  include("overlay/hudtemplates3.oxo")
-  include("overlay/stats.oxo")
-  include("levels/templates/spaceship_assff.oxt")
-  include("levels/templates/spaceship_H2.oxt")
-  include("levels/templates/spaceship_pirate.oxt")
+  include("hudtemplates3.oxo")
+  include("stats.oxo")
+  include("templates/spaceship_assff.oxt")
+  include("templates/spaceship_H2.oxt")
+  include("templates/spaceship_pirate.oxt")
 ?>
 
Index: code/branches/resource2/data/lua/LuaStateInit.lua
===================================================================
--- code/branches/resource2/data/lua/LuaStateInit.lua	(revision 5654)
+++ code/branches/resource2/data/lua/LuaStateInit.lua	(revision 5654)
@@ -0,0 +1,35 @@
+-- Note: luaState is a pointer to the LuaState instance that created this lua state
+
+-- Redirect debug to print
+debug = print
+
+-- Redirect print to the C++ print function
+print = function(s)
+  luaState:luaPrint(s)
+end
+
+-- Create function to log text like COUT, but always prints a line!
+logMessage = function(level, message)
+  luaState:luaLog(level, message)
+end
+
+-- Redirect dofile in order to load with the resource manager
+-- Note: The function does not behave exactly like LuaState::doFile because the
+--       default argument here for the group is not "General" but
+--       "NoResourceGroupProvided". This resolves to the resource group used to
+--       do the current file.
+doFile = function(filename, resourceGroup)
+  local bSearchOtherPaths = (resourceGroup == nil) or false
+  resourceGroup = resourceGroup or "NoResourceGroupProvided"
+  luaState:doFile(filename, resourceGroup, bSearchOtherPaths)
+end
+dofile = doFile
+
+-- Create includeFile function that preparses the file according
+-- to a function provided to the LuaState constructor (in C++)
+-- Note: See the same notes as for doFile
+include = function(filename, resourceGroup)
+  local bSearchOtherPaths = (resourceGroup == nil) or false
+  resourceGroup = resourceGroup or "NoResourceGroupProvided"
+  luaState:includeFile(filename, resourceGroup, bSearchOtherPaths)
+end
Index: code/branches/resource2/data/resources.cfg
===================================================================
--- code/branches/resource2/data/resources.cfg	(revision 5646)
+++ 	(revision )
@@ -1,34 +1,0 @@
-# Resource locations to be added to the 'boostrap' path 
-# This also contains the minimum you need to use the Ogre example framework
-[Bootstrap]
-Zip=packs/OgreCore.zip
-
-# Resource locations to be added to the default path
-[General]
-FileSystem=.
-FileSystem=fonts
-FileSystem=materials/programs
-FileSystem=materials/scripts
-FileSystem=materials/textures
-FileSystem=models
-FileSystem=overlay
-FileSystem=particle
-#FileSystem=../Media/levels
-#FileSystem=../Media/audio
-Zip=packs/cubemap.zip
-#Zip=../Media/packs/cubemapsJS.zip
-#Zip=../Media/packs/dragon.zip
-#Zip=../Media/packs/fresneldemo.zip
-#Zip=../Media/packs/ogretestmap.zip
-Zip=packs/skybox.zip
-FileSystem=gui/fonts
-
-# CEGUI files
-[GUI]
-FileSystem=gui/configs
-FileSystem=gui/fonts
-FileSystem=gui/imagesets
-FileSystem=gui/layouts
-FileSystem=gui/looknfeel
-FileSystem=gui/schemes
-FileSystem=gui/scripts
Index: code/branches/resource2/data/resources.oxr
===================================================================
--- code/branches/resource2/data/resources.oxr	(revision 5646)
+++ code/branches/resource2/data/resources.oxr	(revision 5654)
@@ -1,19 +1,6 @@
-<ResourceGroup name = "General" >
-    <ResourceLocation path = overlay />
-    <ResourceLocation path = particle />
-    <ResourceLocation path = defaultConfig />
-    <ResourceLocation path = levels />
-    <ResourceLocation path = tcl />
-    <ResourceLocation
-      path = test.zip
-      archive = Zip
-      recursive = true
-    />
-</ResourceGroup>
-
-<ResourceGroup name = "GUI" >
-    <ResourceLocation path = gui/configs />
-    <ResourceLocation path = gui/layouts />
-    <ResourceLocation path = gui/schemas />
-    <ResourceLocation path = gui/scripts />
-</ResourceGroup>
+<ResourceCollection resourceGroup = "General" >
+    <ResourceLocation path = "levels" />
+    <ResourceLocation path = "lua" />
+    <ResourceLocation path = "overlay" />
+    <ResourceLocation path = "tcl" />
+</ResourceCollection>
Index: code/branches/resource2/data/resources_graphics.oxr
===================================================================
--- code/branches/resource2/data/resources_graphics.oxr	(revision 5654)
+++ code/branches/resource2/data/resources_graphics.oxr	(revision 5654)
@@ -0,0 +1,10 @@
+<ResourceCollection resourceGroup = "General" >
+    <ResourceLocation path = "particle" />
+</ResourceCollection>
+
+<ResourceCollection resourceGroup = "GUI" >
+    <ResourceLocation path = "gui/configs" />
+    <ResourceLocation path = "gui/layouts" />
+    <ResourceLocation path = "gui/schemes" />
+    <ResourceLocation path = "gui/scripts" />
+</ResourceCollection>
