init.lua 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. --
  2. -- This file contains built-in stuff in Minetest implemented in Lua.
  3. --
  4. -- It is always loaded and executed after registration of the C API,
  5. -- before loading and running any mods.
  6. --
  7. -- Initialize some very basic things
  8. print = core.debug
  9. math.randomseed(os.time())
  10. os.setlocale("C", "numeric")
  11. minetest = core
  12. -- Load other files
  13. local scriptdir = core.get_builtin_path()..DIR_DELIM
  14. local gamepath = scriptdir.."game"..DIR_DELIM
  15. local commonpath = scriptdir.."common"..DIR_DELIM
  16. local asyncpath = scriptdir.."async"..DIR_DELIM
  17. dofile(commonpath.."serialize.lua")
  18. dofile(commonpath.."misc_helpers.lua")
  19. if INIT == "game" then
  20. dofile(gamepath.."init.lua")
  21. elseif INIT == "mainmenu" then
  22. local mainmenuscript = core.setting_get("main_menu_script")
  23. if mainmenuscript ~= nil and mainmenuscript ~= "" then
  24. dofile(mainmenuscript)
  25. else
  26. dofile(core.get_mainmenu_path()..DIR_DELIM.."init.lua")
  27. end
  28. elseif INIT == "async" then
  29. dofile(asyncpath.."init.lua")
  30. else
  31. error(("Unrecognized builtin initialization type %s!"):format(tostring(INIT)))
  32. end