qa_block-cd2025/init.lua

84 lines
1.8 KiB
Lua
Raw Normal View History

2016-09-09 22:49:51 +02:00
print("initialize Starting QA Block")
-- settings
local defaultmodule = "same_recipe"
local print_to_chat = true
-- constants
local filepath = minetest.get_modpath("qa_block").."/checks/"
-- redefine print, copy all output to chat
if print_to_chat then
old_print = print
print = function(...)
local outsting = ""
local out
local x
for x, out in ipairs(arg) do
outsting = (outsting..tostring(out)..'\t')
end
old_print(outsting)
minetest.chat_send_all(outsting)
end
end
-- execute a module
local function do_module( module )
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
print("file "..file.." not found")
else
io.close(f)
local compiled
local executed
local err
local compiled, err = loadfile(file)
if not compiled then
print("syntax error in module file"..file)
print(err)
else
executed, err = pcall(compiled)
if not executed then
print("runtime error appears")
print(err)
end
end
end
print("QA checks finished")
end
2016-09-09 22:49:51 +02:00
minetest.register_chatcommand("qa_block", {
params = "<checkmodule>",
description = "Perform qa block check",
privs = {interact = true},
func = function(name, param)
if param and param ~= "" then
do_module(param)
else
do_module(defaultmodule)
end
return true, "QA checks finished."
end,
})
2016-09-09 22:49:51 +02:00
minetest.register_node("qa_block:block", {
description = "Check mods quality starter block",
tiles = {"default_dirt.png","default_stone.png","default_sand.png"},
groups = {cracky = 3},
sounds = default.node_sound_stone_defaults()
2016-09-09 22:49:51 +02:00
})
minetest.register_on_placenode(function (pos, node)
if node.name == "qa_block:block" then
2016-09-09 22:49:51 +02:00
--- TODO: some selectoin of executed check
do_module(defaultmodule)
2016-09-09 22:49:51 +02:00
minetest.env:add_node(pos, {name="air"})
end
2016-09-09 22:49:51 +02:00
end)