----------------------------------------------- -- Some hardcoded settings and constants ----------------------------------------------- local defaultmodule = "empty" local print_to_chat = minetest.settings:get_bool("qa_block.print_to_chat", true) local log_to_file = minetest.settings:get_bool("qa_block.log_to_file", false) local overwritelog = minetest.settings:get_bool("qa_block.overwrite_log", false) local logdatetime = minetest.settings:get_bool("qa_block.log_date_time", false) local datetimeformat = minetest.settings:get("qa_block.date_time_format") or "%Y-%m-%d %H:%M:%S" local logfilename = minetest.get_worldpath() .. "/qa_block.log" ----------------------------------------------- -- Load external libs and other files ----------------------------------------------- qa_block = {} qa_block.modpath = minetest.get_modpath(minetest.get_current_modname()) qa_block.modutils = dofile(qa_block.modpath.."/modutils.lua") local checks_path = qa_block.modpath.."/checks/" --[[ --temporary buildin usage (again) local smartfs_enabled = false if minetest.get_modpath("smartfs") and smartfs.nodemeta_on_receive_fields then -- nodemeta handling implemented, right version. dofile(qa_block.modpath.."/smartfs_forms.lua") smartfs_enabled = true else print("WARNING: qa_block without (compatible) smartfs is limited functionality") end ]] local smartfs = dofile(qa_block.modpath.."/smartfs.lua") qa_block.smartfs = smartfs dofile(qa_block.modpath.."/smartfs_forms.lua") local smartfs_enabled = true ----------------------------------------------- -- Return a list of keys sorted - Useful when looking for regressions -- https://www.lua.org/pil/19.3.html -- Additional helper to be used in checks ----------------------------------------------- function qa_block.pairsByKeys (t) if not t then return function() return nil end end local a = {} for n in pairs(t) do table.insert(a, n) end table.sort(a) local i = 0 -- iterator variable local iter = function () -- iterator function i = i + 1 if a[i] == nil then return nil else return a[i], t[a[i]] end end return iter end ----------------------------------------------- -- QA-Block functionality - list checks ----------------------------------------------- qa_block.get_checks_list = function() local out = {} local files files = minetest.get_dir_list(checks_path, false) for f=1, #files do local filename = files[f] local outname, _ext = filename:match("(.*)(.lua)$") table.insert(out, outname) end table.sort(out,function(a,b) return a