2 -- This file contains built-in stuff in Minetest implemented in Lua.
4 -- It is always loaded and executed after registration of the C API,
5 -- before loading and running any mods.
8 -- Initialize some very basic things
9 function core.debug(...) core.log(table.concat({...}, "\t")) end
11 local core_print = core.print
12 -- Override native print and use
13 -- terminal if that's turned on
15 local n, t = select("#", ...), {...}
19 core_print(table.concat(t, "\t"))
21 core.print = nil -- don't pollute our namespace
23 math.randomseed(os.time())
24 os.setlocale("C", "numeric")
28 local scriptdir = core.get_builtin_path() .. DIR_DELIM
29 local gamepath = scriptdir .. "game" .. DIR_DELIM
30 local clientpath = scriptdir .. "client" .. DIR_DELIM
31 local commonpath = scriptdir .. "common" .. DIR_DELIM
32 local asyncpath = scriptdir .. "async" .. DIR_DELIM
34 dofile(commonpath .. "strict.lua")
35 dofile(commonpath .. "serialize.lua")
36 dofile(commonpath .. "misc_helpers.lua")
38 if INIT == "game" then
39 dofile(gamepath .. "init.lua")
40 elseif INIT == "mainmenu" then
41 local mm_script = core.settings:get("main_menu_script")
42 if mm_script and mm_script ~= "" then
45 dofile(core.get_mainmenu_path() .. DIR_DELIM .. "init.lua")
47 elseif INIT == "async" then
48 dofile(asyncpath .. "init.lua")
49 elseif INIT == "client" then
51 dofile(clientpath .. "init.lua")
53 error(("Unrecognized builtin initialization type %s!"):format(tostring(INIT)))