From dfacc97a9bc65c6075d0ffdf49ccf52f79c05e95 Mon Sep 17 00:00:00 2001 From: Alexander Weber Date: Tue, 13 Sep 2016 14:14:32 +0200 Subject: [PATCH] in modules print() can be used instead of qa_block.out (override functionality). The output is copied to chatlog. qa_block.out() removed --- checks/same_recipe.lua | 4 ++-- init.lua | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/checks/same_recipe.lua b/checks/same_recipe.lua index 62edabb..411003b 100644 --- a/checks/same_recipe.lua +++ b/checks/same_recipe.lua @@ -78,14 +78,14 @@ for name, def in pairs(minetest.registered_items) do local recipes_for_node = minetest.get_all_craft_recipes(name) if recipes_for_node == nil then if print_no_recipe then - qa_block.out(name, "no_recipe") + print(name, "no_recipe") end else for kn, vn in ipairs(recipes_for_node) do for ku, vu in ipairs(known_recipes) do if vu.output ~= vn.output and is_same_recipe(vu, vn) == true then - qa_block.out('same recipe', vu.output, vn.output) + print('same recipe', vu.output, vn.output) -- print (dump(vu),dump(vn)) --debug end end diff --git a/init.lua b/init.lua index 8a23fbd..522889c 100644 --- a/init.lua +++ b/init.lua @@ -1,31 +1,31 @@ print("initialize Starting QA Block") -qa_block = {} -function qa_block.out(...) +old_print = print +print = function(...) local outsting = "" local out local x for x, out in ipairs(arg) do outsting = (outsting..tostring(out)..'\t') end - print(outsting) + old_print(outsting) minetest.chat_send_all(outsting) end - local filepath = minetest.get_modpath("qa_block").."/checks/" local defaultmodule = "same_recipe" local function do_module( module ) - qa_block.out("QA checks started") + + print("QA checks started") --- TODO: some selectoin of executed check local file = filepath..module..".lua" local f=io.open(file,"r") if not f then - qa_block.out("file "..file.." not found") + print("file "..file.." not found") else io.close(f) local compiled @@ -33,17 +33,17 @@ local function do_module( module ) local err local compiled, err = loadfile(file) if not compiled then - qa_block.out("syntax error in module file"..file) - qa_block.out(err) + print("syntax error in module file"..file) + print(err) else executed, err = pcall(compiled) if not executed then - qa_block.out("runtime error appears") - qa_block.out(err) + print("runtime error appears") + print(err) end end end - qa_block.out("QA checks finished") + print("QA checks finished") end