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 core_print(table.concat({...}, "\t"))
17 core.print = nil -- don't pollute our namespace
19 math.randomseed(os.time())
20 os.setlocale("C", "numeric")
24 local scriptdir = core.get_builtin_path()..DIR_DELIM
25 local gamepath = scriptdir.."game"..DIR_DELIM
26 local commonpath = scriptdir.."common"..DIR_DELIM
27 local asyncpath = scriptdir.."async"..DIR_DELIM
29 dofile(commonpath.."strict.lua")
30 dofile(commonpath.."serialize.lua")
31 dofile(commonpath.."misc_helpers.lua")
33 if INIT == "game" then
34 dofile(gamepath.."init.lua")
35 elseif INIT == "mainmenu" then
36 local mainmenuscript = core.setting_get("main_menu_script")
37 if mainmenuscript ~= nil and mainmenuscript ~= "" then
38 dofile(mainmenuscript)
40 dofile(core.get_mainmenu_path()..DIR_DELIM.."init.lua")
42 elseif INIT == "async" then
43 dofile(asyncpath.."init.lua")
45 error(("Unrecognized builtin initialization type %s!"):format(tostring(INIT)))