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
10 local function concat_args(...)
11 local n, t = select("#", ...), {...}
15 return table.concat(t, "\t")
17 function core.debug(...) core.log(concat_args(...)) end
19 local core_print = core.print
20 -- Override native print and use
21 -- terminal if that's turned on
22 function print(...) core_print(concat_args(...)) end
23 core.print = nil -- don't pollute our namespace
26 math.randomseed(os.time())
30 local scriptdir = core.get_builtin_path()
31 local gamepath = scriptdir .. "game" .. DIR_DELIM
32 local clientpath = scriptdir .. "client" .. DIR_DELIM
33 local commonpath = scriptdir .. "common" .. DIR_DELIM
34 local asyncpath = scriptdir .. "async" .. DIR_DELIM
36 dofile(commonpath .. "vector.lua")
37 dofile(commonpath .. "strict.lua")
38 dofile(commonpath .. "serialize.lua")
39 dofile(commonpath .. "misc_helpers.lua")
41 if INIT == "game" then
42 dofile(gamepath .. "init.lua")
43 assert(not core.get_http_api)
44 elseif INIT == "mainmenu" then
45 local mm_script = core.settings:get("main_menu_script")
46 local custom_loaded = false
47 if mm_script and mm_script ~= "" then
48 local testfile = io.open(mm_script, "r")
53 core.log("info", "Loaded custom main menu script: "..mm_script)
55 core.log("error", "Failed to load custom main menu script: "..mm_script)
56 core.log("info", "Falling back to default main menu script")
59 if not custom_loaded then
60 dofile(core.get_mainmenu_path() .. DIR_DELIM .. "init.lua")
62 elseif INIT == "async" then
63 dofile(asyncpath .. "mainmenu.lua")
64 elseif INIT == "async_game" then
65 dofile(asyncpath .. "game.lua")
66 elseif INIT == "client" then
67 dofile(clientpath .. "init.lua")
69 error(("Unrecognized builtin initialization type %s!"):format(tostring(INIT)))