diff --git a/init.lua b/init.lua index aa1adcf..cda34f9 100644 --- a/init.lua +++ b/init.lua @@ -71,7 +71,7 @@ end -- aliases -- more aliases are implemented below: --- modlib.[mod|log|conf|player] are aliases of modlib.minetest.[mod|log|conf|player] respectively +-- modlib.[mod|conf] are aliases of modlib.minetest.[mod|conf] respectively modules.string = "text" modules.number = "math" @@ -99,10 +99,6 @@ end local function load_module(self, module_name_or_alias) local module_name = modules[module_name_or_alias] if not module_name then - -- Handle modlib.[log|player] aliases for the minetest.[log|player] modules - if module_name_or_alias == "log" then - return modlib.minetest.log - end -- no such module return end diff --git a/minetest.lua b/minetest.lua index 52b3129..e7f19e1 100644 --- a/minetest.lua +++ b/minetest.lua @@ -3,7 +3,6 @@ local _ENV = {} local components = {} for _, value in pairs{ "mod", - "log", "conf", -- deprecated "luon", "raycast", diff --git a/minetest/log.lua b/minetest/log.lua deleted file mode 100644 index fca91d3..0000000 --- a/minetest/log.lua +++ /dev/null @@ -1,87 +0,0 @@ --- Localize globals -local ipairs, minetest, modlib, os, pairs, table = ipairs, minetest, modlib, os, pairs, table - --- Set environment -local _ENV = {} -setfenv(1, _ENV) - --- Log helpers - write to log, force writing to file -minetest.mkdir(minetest.get_worldpath() .. "/logs") -channels = {} -last_day = os.date("%d") -function get_path(logname) - return minetest.get_worldpath() .. "/logs/" .. logname -end -function create_channel(title) - local dir = get_path(title) - minetest.mkdir(dir) - channels[title] = {dirname = dir, queue = {}} - write(title, "Initialisation") -end -function write(channelname, msg) - local channel = channels[channelname] - local current_day = os.date("%d") - if current_day ~= last_day then - last_day = current_day - write_to_file(channelname, channel, os.date("%Y-%m-%d")) - end - table.insert(channel.queue, os.date("[%H:%M:%S] ") .. msg) -end -function write_to_all(msg) - for channelname, _ in pairs(channels) do - write(channelname, msg) - end -end -function write_to_file(name, channel, current_date) - if not channel then - channel = channels[name] - end - if #(channel.queue) > 0 then - local filename = channel.dirname .. "/" .. (current_date or os.date("%Y-%m-%d")) .. ".txt" - local rope = {} - for _, msg in ipairs(channel.queue) do - table.insert(rope, msg) - end - modlib.file.append(filename, table.concat(rope, "\n") .. "\n") - channels[name].queue = {} - end -end -function write_all_to_file() - local current_date = os.date("%Y-%m-%d") - for name, channel in pairs(channels) do - write_to_file(name, channel, current_date) - end -end -function write_safe(channelname, msg) - write(channelname, msg) - write_all_to_file() -end - -local timer = 0 - -minetest.register_globalstep( - function(dtime) - timer = timer + dtime - if timer > 5 then - write_all_to_file() - timer = 0 - end - end -) - -minetest.register_on_mods_loaded( - function() - write_to_all("Mods loaded") - end -) - -minetest.register_on_shutdown( - function() - write_to_all("Shutdown") - write_all_to_file() - end -) - - --- Export environment -return _ENV \ No newline at end of file