diff options
author | ShadowNinja <shadowninja@minetest.net> | 2014-04-27 17:55:49 -0400 |
---|---|---|
committer | ShadowNinja <shadowninja@minetest.net> | 2014-05-07 17:14:23 -0400 |
commit | 1cd512913e4d4ad1fb43d4b6e3d7971bb6c67528 (patch) | |
tree | 8c1e2c708f567656684e89faee4f7c8e6c5ec673 /builtin | |
parent | fef2729fd0945601e6772780514ee55fec35b068 (diff) | |
download | minetest-1cd512913e4d4ad1fb43d4b6e3d7971bb6c67528.tar.gz minetest-1cd512913e4d4ad1fb43d4b6e3d7971bb6c67528.tar.bz2 minetest-1cd512913e4d4ad1fb43d4b6e3d7971bb6c67528.zip |
Organize builtin into subdirectories
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/async/init.lua | 18 | ||||
-rw-r--r-- | builtin/async_env.lua | 21 | ||||
-rw-r--r-- | builtin/async_event.lua | 45 | ||||
-rw-r--r-- | builtin/builtin.lua | 32 | ||||
-rw-r--r-- | builtin/common/async_event.lua | 42 | ||||
-rw-r--r-- | builtin/common/misc_helpers.lua (renamed from builtin/misc_helpers.lua) | 0 | ||||
-rw-r--r-- | builtin/common/serialize.lua (renamed from builtin/serialize.lua) | 0 | ||||
-rw-r--r-- | builtin/common/vector.lua (renamed from builtin/vector.lua) | 0 | ||||
-rw-r--r-- | builtin/game/auth.lua (renamed from builtin/auth.lua) | 0 | ||||
-rw-r--r-- | builtin/game/chatcommands.lua (renamed from builtin/chatcommands.lua) | 0 | ||||
-rw-r--r-- | builtin/game/deprecated.lua (renamed from builtin/deprecated.lua) | 0 | ||||
-rw-r--r-- | builtin/game/detached_inventory.lua (renamed from builtin/detached_inventory.lua) | 0 | ||||
-rw-r--r-- | builtin/game/falling.lua (renamed from builtin/falling.lua) | 2 | ||||
-rw-r--r-- | builtin/game/features.lua (renamed from builtin/features.lua) | 0 | ||||
-rw-r--r-- | builtin/game/forceloading.lua (renamed from builtin/forceloading.lua) | 0 | ||||
-rw-r--r-- | builtin/game/init.lua | 23 | ||||
-rw-r--r-- | builtin/game/item.lua (renamed from builtin/item.lua) | 0 | ||||
-rw-r--r-- | builtin/game/item_entity.lua (renamed from builtin/item_entity.lua) | 2 | ||||
-rw-r--r-- | builtin/game/misc.lua (renamed from builtin/misc.lua) | 0 | ||||
-rw-r--r-- | builtin/game/privileges.lua (renamed from builtin/privileges.lua) | 0 | ||||
-rw-r--r-- | builtin/game/register.lua (renamed from builtin/misc_register.lua) | 0 | ||||
-rw-r--r-- | builtin/game/statbars.lua (renamed from builtin/statbars.lua) | 0 | ||||
-rw-r--r-- | builtin/game/static_spawn.lua (renamed from builtin/static_spawn.lua) | 0 | ||||
-rw-r--r-- | builtin/game/voxelarea.lua (renamed from builtin/voxelarea.lua) | 0 | ||||
-rw-r--r-- | builtin/init.lua | 34 | ||||
-rw-r--r-- | builtin/mainmenu/filterlist.lua (renamed from builtin/filterlist.lua) | 0 | ||||
-rw-r--r-- | builtin/mainmenu/gamemgr.lua (renamed from builtin/gamemgr.lua) | 0 | ||||
-rw-r--r-- | builtin/mainmenu/init.lua (renamed from builtin/mainmenu.lua) | 23 | ||||
-rw-r--r-- | builtin/mainmenu/menubar.lua (renamed from builtin/mm_menubar.lua) | 0 | ||||
-rw-r--r-- | builtin/mainmenu/modmgr.lua (renamed from builtin/modmgr.lua) | 0 | ||||
-rw-r--r-- | builtin/mainmenu/modstore.lua (renamed from builtin/modstore.lua) | 0 | ||||
-rw-r--r-- | builtin/mainmenu/textures.lua (renamed from builtin/mm_textures.lua) | 0 |
32 files changed, 129 insertions, 113 deletions
diff --git a/builtin/async/init.lua b/builtin/async/init.lua new file mode 100644 index 000000000..79b1a0a6c --- /dev/null +++ b/builtin/async/init.lua @@ -0,0 +1,18 @@ +engine.log("info", "Initializing Asynchronous environment") + +local core = engine or minetest + +function core.job_processor(serialized_func, serialized_param) + local func = loadstring(serialized_func) + local param = core.deserialize(serialized_param) + local retval = nil + + if type(func) == "function" then + retval = core.serialize(func(param)) + else + core.log("error", "ASYNC WORKER: Unable to deserialize function") + end + + return retval or core.serialize(nil) +end + diff --git a/builtin/async_env.lua b/builtin/async_env.lua deleted file mode 100644 index cdcb82ee3..000000000 --- a/builtin/async_env.lua +++ /dev/null @@ -1,21 +0,0 @@ -engine.log("info", "Initializing Asynchronous environment") -local tbl = engine or minetest - -minetest = tbl -dofile(SCRIPTDIR .. DIR_DELIM .. "serialize.lua") -dofile(SCRIPTDIR .. DIR_DELIM .. "misc_helpers.lua") - -function tbl.job_processor(serialized_func, serialized_param) - local func = loadstring(serialized_func) - local param = tbl.deserialize(serialized_param) - local retval = nil - - if type(func) == "function" then - retval = tbl.serialize(func(param)) - else - tbl.log("error", "ASYNC WORKER: Unable to deserialize function") - end - - return retval or tbl.serialize(nil) -end - diff --git a/builtin/async_event.lua b/builtin/async_event.lua deleted file mode 100644 index 2c3fb8fa7..000000000 --- a/builtin/async_event.lua +++ /dev/null @@ -1,45 +0,0 @@ -local tbl = engine or minetest - -local SCRIPTDIR = SCRIPTDIR or tbl.get_scriptdir() -minetest = tbl -dofile(SCRIPTDIR .. DIR_DELIM .. "serialize.lua") - -tbl.async_jobs = {} - -local function handle_job(jobid, serialized_retval) - local retval = tbl.deserialize(serialized_retval) - assert(type(tbl.async_jobs[jobid]) == "function") - tbl.async_jobs[jobid](retval) - tbl.async_jobs[jobid] = nil -end - -if engine ~= nil then - tbl.async_event_handler = handle_job -else - minetest.register_globalstep(function(dtime) - for i, job in ipairs(tbl.get_finished_jobs()) do - handle_job(job.jobid, job.retval) - end - end) -end - -function tbl.handle_async(func, parameter, callback) - -- Serialize function - local serialized_func = string.dump(func) - - assert(serialized_func ~= nil) - - -- Serialize parameters - local serialized_param = tbl.serialize(parameter) - - if serialized_param == nil then - return false - end - - local jobid = tbl.do_async_callback(serialized_func, serialized_param) - - tbl.async_jobs[jobid] = callback - - return true -end - diff --git a/builtin/builtin.lua b/builtin/builtin.lua deleted file mode 100644 index 1babe006f..000000000 --- a/builtin/builtin.lua +++ /dev/null @@ -1,32 +0,0 @@ --- --- This file contains built-in stuff in Minetest implemented in Lua. --- --- It is always loaded and executed after registration of the C API, --- before loading and running any mods. --- - --- Initialize some very basic things -print = minetest.debug -math.randomseed(os.time()) -os.setlocale("C", "numeric") - --- Load other files -local modpath = minetest.get_modpath("__builtin") -dofile(modpath.."/serialize.lua") -dofile(modpath.."/misc_helpers.lua") -dofile(modpath.."/item.lua") -dofile(modpath.."/misc_register.lua") -dofile(modpath.."/item_entity.lua") -dofile(modpath.."/deprecated.lua") -dofile(modpath.."/misc.lua") -dofile(modpath.."/privileges.lua") -dofile(modpath.."/auth.lua") -dofile(modpath.."/chatcommands.lua") -dofile(modpath.."/static_spawn.lua") -dofile(modpath.."/detached_inventory.lua") -dofile(modpath.."/falling.lua") -dofile(modpath.."/features.lua") -dofile(modpath.."/voxelarea.lua") -dofile(modpath.."/vector.lua") -dofile(modpath.."/forceloading.lua") -dofile(modpath.."/statbars.lua") diff --git a/builtin/common/async_event.lua b/builtin/common/async_event.lua new file mode 100644 index 000000000..ef4bf4354 --- /dev/null +++ b/builtin/common/async_event.lua @@ -0,0 +1,42 @@ + +local core = engine or minetest + +core.async_jobs = {} + +local function handle_job(jobid, serialized_retval) + local retval = core.deserialize(serialized_retval) + assert(type(core.async_jobs[jobid]) == "function") + core.async_jobs[jobid](retval) + core.async_jobs[jobid] = nil +end + +if engine ~= nil then + core.async_event_handler = handle_job +else + minetest.register_globalstep(function(dtime) + for i, job in ipairs(core.get_finished_jobs()) do + handle_job(job.jobid, job.retval) + end + end) +end + +function core.handle_async(func, parameter, callback) + -- Serialize function + local serialized_func = string.dump(func) + + assert(serialized_func ~= nil) + + -- Serialize parameters + local serialized_param = core.serialize(parameter) + + if serialized_param == nil then + return false + end + + local jobid = core.do_async_callback(serialized_func, serialized_param) + + core.async_jobs[jobid] = callback + + return true +end + diff --git a/builtin/misc_helpers.lua b/builtin/common/misc_helpers.lua index 9c7349726..9c7349726 100644 --- a/builtin/misc_helpers.lua +++ b/builtin/common/misc_helpers.lua diff --git a/builtin/serialize.lua b/builtin/common/serialize.lua index 93fffe80d..93fffe80d 100644 --- a/builtin/serialize.lua +++ b/builtin/common/serialize.lua diff --git a/builtin/vector.lua b/builtin/common/vector.lua index 77944b612..77944b612 100644 --- a/builtin/vector.lua +++ b/builtin/common/vector.lua diff --git a/builtin/auth.lua b/builtin/game/auth.lua index b6cca609c..b6cca609c 100644 --- a/builtin/auth.lua +++ b/builtin/game/auth.lua diff --git a/builtin/chatcommands.lua b/builtin/game/chatcommands.lua index f8df83d8e..f8df83d8e 100644 --- a/builtin/chatcommands.lua +++ b/builtin/game/chatcommands.lua diff --git a/builtin/deprecated.lua b/builtin/game/deprecated.lua index d8b578d48..d8b578d48 100644 --- a/builtin/deprecated.lua +++ b/builtin/game/deprecated.lua diff --git a/builtin/detached_inventory.lua b/builtin/game/detached_inventory.lua index 3757f1387..3757f1387 100644 --- a/builtin/detached_inventory.lua +++ b/builtin/game/detached_inventory.lua diff --git a/builtin/falling.lua b/builtin/game/falling.lua index 7ac348bdb..93d17221a 100644 --- a/builtin/falling.lua +++ b/builtin/game/falling.lua @@ -4,7 +4,7 @@ -- Falling stuff -- -minetest.register_entity("__builtin:falling_node", { +minetest.register_entity(":__builtin:falling_node", { initial_properties = { physical = true, collide_with_objects = false, diff --git a/builtin/features.lua b/builtin/game/features.lua index f3de3ba21..f3de3ba21 100644 --- a/builtin/features.lua +++ b/builtin/game/features.lua diff --git a/builtin/forceloading.lua b/builtin/game/forceloading.lua index 84895792b..84895792b 100644 --- a/builtin/forceloading.lua +++ b/builtin/game/forceloading.lua diff --git a/builtin/game/init.lua b/builtin/game/init.lua new file mode 100644 index 000000000..b878a2664 --- /dev/null +++ b/builtin/game/init.lua @@ -0,0 +1,23 @@ + +local scriptpath = minetest.get_builtin_path()..DIR_DELIM +local commonpath = scriptpath.."common"..DIR_DELIM +local gamepath = scriptpath.."game"..DIR_DELIM + +dofile(commonpath.."vector.lua") + +dofile(gamepath.."item.lua") +dofile(gamepath.."register.lua") +dofile(gamepath.."item_entity.lua") +dofile(gamepath.."deprecated.lua") +dofile(gamepath.."misc.lua") +dofile(gamepath.."privileges.lua") +dofile(gamepath.."auth.lua") +dofile(gamepath.."chatcommands.lua") +dofile(gamepath.."static_spawn.lua") +dofile(gamepath.."detached_inventory.lua") +dofile(gamepath.."falling.lua") +dofile(gamepath.."features.lua") +dofile(gamepath.."voxelarea.lua") +dofile(gamepath.."forceloading.lua") +dofile(gamepath.."statbars.lua") + diff --git a/builtin/item.lua b/builtin/game/item.lua index 002c14f5e..002c14f5e 100644 --- a/builtin/item.lua +++ b/builtin/game/item.lua diff --git a/builtin/item_entity.lua b/builtin/game/item_entity.lua index 0dcc2dc2d..8150e6da1 100644 --- a/builtin/item_entity.lua +++ b/builtin/game/item_entity.lua @@ -8,7 +8,7 @@ function minetest.spawn_item(pos, item) return obj end -minetest.register_entity("__builtin:item", { +minetest.register_entity(":__builtin:item", { initial_properties = { hp_max = 1, physical = true, diff --git a/builtin/misc.lua b/builtin/game/misc.lua index 82cc527cd..82cc527cd 100644 --- a/builtin/misc.lua +++ b/builtin/game/misc.lua diff --git a/builtin/privileges.lua b/builtin/game/privileges.lua index 244aa453c..244aa453c 100644 --- a/builtin/privileges.lua +++ b/builtin/game/privileges.lua diff --git a/builtin/misc_register.lua b/builtin/game/register.lua index 99c5115c4..99c5115c4 100644 --- a/builtin/misc_register.lua +++ b/builtin/game/register.lua diff --git a/builtin/statbars.lua b/builtin/game/statbars.lua index ca656a974..ca656a974 100644 --- a/builtin/statbars.lua +++ b/builtin/game/statbars.lua diff --git a/builtin/static_spawn.lua b/builtin/game/static_spawn.lua index e8c107d86..e8c107d86 100644 --- a/builtin/static_spawn.lua +++ b/builtin/game/static_spawn.lua diff --git a/builtin/voxelarea.lua b/builtin/game/voxelarea.lua index 93bbf73a8..93bbf73a8 100644 --- a/builtin/voxelarea.lua +++ b/builtin/game/voxelarea.lua diff --git a/builtin/init.lua b/builtin/init.lua new file mode 100644 index 000000000..9969111b8 --- /dev/null +++ b/builtin/init.lua @@ -0,0 +1,34 @@ +-- +-- This file contains built-in stuff in Minetest implemented in Lua. +-- +-- It is always loaded and executed after registration of the C API, +-- before loading and running any mods. +-- + +local core = minetest or engine +minetest = core + +-- Initialize some very basic things +print = core.debug +math.randomseed(os.time()) +os.setlocale("C", "numeric") + +-- Load other files +local scriptdir = core.get_builtin_path()..DIR_DELIM +local gamepath = scriptdir.."game"..DIR_DELIM +local commonpath = scriptdir.."common"..DIR_DELIM +local asyncpath = scriptdir.."async"..DIR_DELIM + +dofile(commonpath.."serialize.lua") +dofile(commonpath.."misc_helpers.lua") + +if INIT == "game" then + dofile(gamepath.."init.lua") +elseif INIT == "mainmenu" then + dofile(core.get_mainmenu_path()..DIR_DELIM.."init.lua") +elseif INIT == "async" then + dofile(asyncpath.."init.lua") +else + error(("Unrecognized builtin initialization type %s!"):format(tostring(INIT))) +end + diff --git a/builtin/filterlist.lua b/builtin/mainmenu/filterlist.lua index 379a5cea9..379a5cea9 100644 --- a/builtin/filterlist.lua +++ b/builtin/mainmenu/filterlist.lua diff --git a/builtin/gamemgr.lua b/builtin/mainmenu/gamemgr.lua index c99c2de21..c99c2de21 100644 --- a/builtin/gamemgr.lua +++ b/builtin/mainmenu/gamemgr.lua diff --git a/builtin/mainmenu.lua b/builtin/mainmenu/init.lua index 67e0113bc..d78a668c5 100644 --- a/builtin/mainmenu.lua +++ b/builtin/mainmenu/init.lua @@ -1,8 +1,14 @@ -print = engine.debug -math.randomseed(os.time()) -os.setlocale("C", "numeric") -local scriptpath = engine.get_scriptdir() +local menupath = engine.get_mainmenu_path()..DIR_DELIM +local commonpath = engine.get_builtin_path()..DIR_DELIM.."common"..DIR_DELIM + +dofile(menupath.."filterlist.lua") +dofile(menupath.."modmgr.lua") +dofile(menupath.."modstore.lua") +dofile(menupath.."gamemgr.lua") +dofile(menupath.."textures.lua") +dofile(menupath.."menubar.lua") +dofile(commonpath.."async_event.lua") mt_color_grey = "#AAAAAA" mt_color_blue = "#0000DD" @@ -11,15 +17,6 @@ mt_color_dark_green = "#003300" --for all other colors ask sfan5 to complete his worK! -dofile(scriptpath .. DIR_DELIM .. "misc_helpers.lua") -dofile(scriptpath .. DIR_DELIM .. "filterlist.lua") -dofile(scriptpath .. DIR_DELIM .. "modmgr.lua") -dofile(scriptpath .. DIR_DELIM .. "modstore.lua") -dofile(scriptpath .. DIR_DELIM .. "gamemgr.lua") -dofile(scriptpath .. DIR_DELIM .. "mm_textures.lua") -dofile(scriptpath .. DIR_DELIM .. "mm_menubar.lua") -dofile(scriptpath .. DIR_DELIM .. "async_event.lua") - menu = {} local tabbuilder = {} local worldlist = nil diff --git a/builtin/mm_menubar.lua b/builtin/mainmenu/menubar.lua index 2e4d5f8b8..2e4d5f8b8 100644 --- a/builtin/mm_menubar.lua +++ b/builtin/mainmenu/menubar.lua diff --git a/builtin/modmgr.lua b/builtin/mainmenu/modmgr.lua index eeb65add1..eeb65add1 100644 --- a/builtin/modmgr.lua +++ b/builtin/mainmenu/modmgr.lua diff --git a/builtin/modstore.lua b/builtin/mainmenu/modstore.lua index ef7fd0165..ef7fd0165 100644 --- a/builtin/modstore.lua +++ b/builtin/mainmenu/modstore.lua diff --git a/builtin/mm_textures.lua b/builtin/mainmenu/textures.lua index 998fc2199..998fc2199 100644 --- a/builtin/mm_textures.lua +++ b/builtin/mainmenu/textures.lua |