No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

init.lua 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. -- this is the first file executed when the application starts
  2. -- we have to load the first modules form here
  3. -- setup logger
  4. g_logger.setLogFile(g_resources.getWorkDir() .. g_app.getCompactName() .. ".log")
  5. g_logger.info(os.date("== application started at %b %d %Y %X"))
  6. -- print first terminal message
  7. 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())
  8. -- add data directory to the search path
  9. if not g_resources.addSearchPath(g_resources.getWorkDir() .. "data", true) then
  10. g_logger.fatal("Unable to add data directory to the search path.")
  11. end
  12. -- add modules directory to the search path
  13. if not g_resources.addSearchPath(g_resources.getWorkDir() .. "modules", true) then
  14. g_logger.fatal("Unable to add modules directory to the search path.")
  15. end
  16. -- try to add mods path too
  17. g_resources.addSearchPath(g_resources.getWorkDir() .. "mods", true)
  18. -- setup directory for saving configurations
  19. g_resources.setupUserWriteDir(('%s/'):format(g_app.getCompactName()))
  20. -- search all packages
  21. g_resources.searchAndAddPackages('/', '.otpkg', true)
  22. -- load settings
  23. g_configs.loadSettings("/config.otml")
  24. g_modules.discoverModules()
  25. -- libraries modules 0-99
  26. g_modules.autoLoadModules(99)
  27. g_modules.ensureModuleLoaded("corelib")
  28. g_modules.ensureModuleLoaded("gamelib")
  29. -- client modules 100-499
  30. g_modules.autoLoadModules(499)
  31. g_modules.ensureModuleLoaded("client")
  32. -- game modules 500-999
  33. g_modules.autoLoadModules(999)
  34. g_modules.ensureModuleLoaded("game_interface")
  35. -- mods 1000-9999
  36. g_modules.autoLoadModules(9999)
  37. local script = '/' .. g_app.getCompactName() .. 'rc.lua'
  38. if g_resources.fileExists(script) then
  39. dofile(script)
  40. end