1 core.log("info", "Initializing asynchronous environment (game)")
3 local function pack2(...)
4 return {n=select('#', ...), ...}
7 -- Entrypoint to run async jobs, called by C++
8 function core.job_processor(func, params)
9 local retval = pack2(func(unpack(params, 1, params.n)))
14 -- Import a bunch of individual files from builtin/game/
15 local gamepath = core.get_builtin_path() .. "game" .. DIR_DELIM
16 local commonpath = core.get_builtin_path() .. "common" .. DIR_DELIM
18 local builtin_shared = {}
20 dofile(gamepath .. "constants.lua")
21 assert(loadfile(commonpath .. "item_s.lua"))(builtin_shared)
22 dofile(gamepath .. "misc_s.lua")
23 dofile(gamepath .. "features.lua")
24 dofile(gamepath .. "voxelarea.lua")
26 -- Transfer of globals
28 local all = assert(core.transferred_globals)
29 core.transferred_globals = nil
31 all.registered_nodes = {}
32 all.registered_craftitems = {}
33 all.registered_tools = {}
34 for k, v in pairs(all.registered_items) do
35 -- Disable further modification
36 setmetatable(v, {__newindex = {}})
37 -- Reassemble the other tables
38 if v.type == "node" then
39 all.registered_nodes[k] = v
40 elseif v.type == "craftitem" then
41 all.registered_craftitems[k] = v
42 elseif v.type == "tool" then
43 all.registered_tools[k] = v
47 for k, v in pairs(all) do
52 -- For tables that are indexed by item name:
53 -- If table[X] does not exist, default to table[core.registered_aliases[X]]
54 local alias_metatable = {
55 __index = function(t, name)
56 return rawget(t, core.registered_aliases[name])
59 setmetatable(core.registered_items, alias_metatable)
60 setmetatable(core.registered_nodes, alias_metatable)
61 setmetatable(core.registered_craftitems, alias_metatable)
62 setmetatable(core.registered_tools, alias_metatable)
64 builtin_shared.cache_content_ids()