-- Copyright 2005 Double Fine Productions
-- All rights reserved.  Proprietary and Confidential.
--
-- Loaded by ReferenceApp on startup.
--
-- $Id: //mana/Buddha/Main/Data/Config/boot.lua#1 $

-- To be used within boot.lua
function safe_load(file, missing_is_ok)
	local fn, err = loadfile(file)
        if fn then
		local success
		success, err = pcall(fn)
		if success then err = nil end	-- silly lua api
	else
		if missing_is_ok and string.find(err, "cannot read") then return end
	end
	if err then Trace(TT_Lua, TL_Warning, err) end
end		

-- To be used from the console.  Also used by emacs.
function reload(file)
	local fn, err = loadfile(file)
	if fn then
		local success
		success, result = pcall(fn)
		if success then
			if OnClassReloaded and type(result) == "table" then
				-- it's probably a lua class; notify the script system
				OnClassReloaded(file, fn, result)
			else
				print(string.format("Reloaded '%s'", file))
			end
		else
			err = result
		end
	end

	if err then
		print(err)
	end
end

safe_load("Data/Config/user.lua", true)
safe_load("Data/Script/Utils/Clump.lua")
safe_load("Data/Script/Utils/Debug.lua")
safe_load("Data/Script/Utils/ScriptSystem.lua")
safe_load("Data/Script/Utils/Util.lua")
safe_load("Data/Script/Utils/GameUtil.lua")
safe_load("Data/Script/Utils/ActionGlue.lua")
safe_load("Data/Test/Utils/TestSystem.lua")

safe_load("Data/Script/SeedStartup.lua")


