2012-06-20 02:15:56 +02:00
-- this is the first file executed when the application starts
-- we have to load the first modules form here
-- setup logger
g_logger.setLogFile ( g_resources.getWorkDir ( ) .. g_app.getCompactName ( ) .. " .log " )
2013-02-10 05:28:47 +01:00
g_logger.info ( os.date ( " == application started at %b %d %Y %X " ) )
2012-06-20 02:15:56 +02:00
-- print first terminal message
2012-07-15 01:20:38 +02:00
g_logger.info ( g_app.getName ( ) .. ' ' .. g_app.getVersion ( ) .. ' rev ' .. g_app.getBuildRevision ( ) .. ' ( ' .. g_app.getBuildCommit ( ) .. ' ) built on ' .. g_app.getBuildDate ( ) .. ' for arch ' .. g_app.getBuildArch ( ) )
2012-06-20 02:15:56 +02:00
2013-01-18 23:39:11 +01:00
-- add data directory to the search path
if not g_resources.addSearchPath ( g_resources.getWorkDir ( ) .. " data " , true ) then
2013-02-10 06:01:33 +01:00
g_logger.fatal ( " Unable to add data directory to the search path. " )
2013-01-18 23:39:11 +01:00
end
2012-06-20 02:15:56 +02:00
-- add modules directory to the search path
2012-07-16 21:35:14 +02:00
if not g_resources.addSearchPath ( g_resources.getWorkDir ( ) .. " modules " , true ) then
2012-07-05 22:03:41 +02:00
g_logger.fatal ( " Unable to add modules directory to the search path. " )
2012-06-20 02:15:56 +02:00
end
2012-07-17 01:04:45 +02:00
-- try to add mods path too
g_resources.addSearchPath ( g_resources.getWorkDir ( ) .. " mods " , true )
2012-06-20 02:15:56 +02:00
-- setup directory for saving configurations
2012-07-16 21:35:14 +02:00
g_resources.setupUserWriteDir ( g_app.getCompactName ( ) )
-- search all packages
g_resources.searchAndAddPackages ( ' / ' , ' .otpkg ' , true )
2012-06-20 02:15:56 +02:00
2014-04-01 14:54:13 +02:00
-- load settings
2014-03-31 18:43:31 +02:00
g_configs.loadSettings ( " /config.otml " )
2012-06-20 02:15:56 +02:00
g_modules.discoverModules ( )
2012-07-18 01:49:21 +02:00
-- libraries modules 0-99
2012-09-01 01:33:51 +02:00
g_modules.autoLoadModules ( 99 )
2012-06-20 02:15:56 +02:00
g_modules.ensureModuleLoaded ( " corelib " )
2012-07-18 01:49:21 +02:00
g_modules.ensureModuleLoaded ( " gamelib " )
2012-06-20 02:15:56 +02:00
-- client modules 100-499
2012-07-15 01:20:38 +02:00
g_modules.autoLoadModules ( 499 )
2012-06-20 02:15:56 +02:00
g_modules.ensureModuleLoaded ( " client " )
-- game modules 500-999
2012-09-01 01:33:51 +02:00
g_modules.autoLoadModules ( 999 )
2012-07-18 01:49:21 +02:00
g_modules.ensureModuleLoaded ( " game_interface " )
2012-06-20 02:15:56 +02:00
2012-07-17 01:04:45 +02:00
-- mods 1000-9999
2012-06-20 02:15:56 +02:00
g_modules.autoLoadModules ( 9999 )
2013-12-26 21:31:55 +01:00
local script = ' / ' .. g_app.getCompactName ( ) .. ' rc.lua '
2013-02-10 05:54:20 +01:00
2013-01-27 10:44:15 +01:00
if g_resources.fileExists ( script ) then
dofile ( script )
2013-02-10 05:28:47 +01:00
end