Clean up debug messaging

This commit is contained in:
Wuzzy 2019-08-28 17:54:05 +02:00
parent 158f8966d7
commit 3795496672
8 changed files with 16 additions and 36 deletions

View File

@ -90,8 +90,6 @@ function armor.get_texture(player, base)
end
end
-- print("[armor] Got armor texture: " .. image)
return image
end
@ -136,8 +134,6 @@ function armor.get_groups(player)
groups.fleshy = groups.fleshy - 10
end
-- print("[armor] Armor groups: " .. dump(groups))
return groups
end
@ -217,7 +213,6 @@ for mat_index, matdef in ipairs(armor.materials) do
local mat = matdef[1]
local armor_def = math.floor(matdef[4] / #armor.slots)
-- print("Material " .. mat .. ": " .. armor_def)
for _, slot in ipairs(armor.slots) do
local prettystring = slot:gsub(

View File

@ -284,8 +284,6 @@ default.ui.register_page("default:bookshelf", form_bookshelf)
function default.ui.receive_fields(player, form_name, fields)
local name = player:get_player_name()
-- print("Received formspec fields from '"..name.."': "..dump(fields))
if fields.tab_crafting then
minetest.show_formspec(name, "crafting:crafting", crafting.get_formspec(name))
elseif minetest.get_modpath("armor") ~= nil and fields.tab_armor then

View File

@ -177,16 +177,13 @@ minetest.register_abm( -- leaf decay
chance = 3,
action = function(p0, node, _, _)
--print("leafdecay ABM at "..p0.x..", "..p0.y..", "..p0.z..")")
local do_preserve = false
local d = minetest.registered_nodes[node.name].groups.leafdecay
if not d or d == 0 then
--print("not groups.leafdecay")
return
end
local n0 = minetest.get_node(p0)
if n0.param2 ~= 0 then
--print("param2 ~= 0")
return
end
local p0_hash = nil
@ -198,10 +195,8 @@ minetest.register_abm( -- leaf decay
local reg = minetest.registered_nodes[n.name]
-- Assume ignore is a trunk, to make the thing work at the border of the active area
if n.name == "ignore" or (reg and reg.groups.tree and reg.groups.tree ~= 0) then
--print("cached trunk still exists")
return
end
--print("cached trunk is invalid")
-- Cache is invalid
table.remove(default.leafdecay_trunk_cache, p0_hash)
end
@ -216,7 +211,6 @@ minetest.register_abm( -- leaf decay
if p1 then
do_preserve = true
if default.leafdecay_enable_cache then
--print("caching trunk")
-- Cache the trunk
default.leafdecay_trunk_cache[p0_hash] = p1
end

View File

@ -1562,7 +1562,6 @@ minetest.register_node(
meta:set_string("text", "")
end,
on_receive_fields = function(pos, formname, fields, sender)
--print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields))
if fields.text == nil then return end
local meta = minetest.get_meta(pos)
minetest.log("action", (sender:get_player_name() or "")..

View File

@ -288,7 +288,6 @@ function mobs:register_mob(name, def)
and math.random(1, self.replace_rate) == 1 then
local pos = self.object:get_pos()
pos.y = pos.y + self.replace_offset
-- print ("replace node = ".. minetest.get_node(pos).name, pos.y)
if self.replace_what and self.object:get_velocity().y == 0 and #minetest.find_nodes_in_area(pos, pos, self.replace_what) > 0 then
--and self.state == "stand" then
if self.on_replace ~= nil then
@ -393,7 +392,7 @@ function mobs:register_mob(name, def)
pos.y = pos.y + self.collisionbox[2] -- foot level
local nod = minetest.get_node_or_nil(pos)
if not nod then return end ; -- print ("standing in "..nod.name)
if not nod then return end
local nodef = minetest.registered_nodes[nod.name]
pos.y = pos.y + 1
@ -425,7 +424,6 @@ function mobs:register_mob(name, def)
local pos = self.object:get_pos()
pos.y = (pos.y + self.collisionbox[2]) - 0.2
local nod = minetest.get_node(pos)
--print ("standing on:", nod.name, pos.y)
if not nod
or not minetest.registered_nodes[nod.name]
or minetest.registered_nodes[nod.name].walkable == false then
@ -439,7 +437,6 @@ function mobs:register_mob(name, def)
y = pos.y,
z = pos.z + self.direction.z
})
--print ("in front:", nod.name, pos.y)
if nod and nod.name and
(nod.name ~= "air"
or self.walk_chance == 0) then
@ -804,7 +801,6 @@ function mobs:register_mob(name, def)
-- water swimmers cannot move out of water
if self.fly and self.fly_in == "default:water_source" and not lp then
print ("out of water")
self.set_velocity(self, 0)
self.state = "flop" -- change to undefined state so nothing more happens
self:set_animation("stand")
@ -931,7 +927,6 @@ function mobs:register_mob(name, def)
elseif self.state == "attack"
and self.attack_type == "dogfight" then
if not self.attack.player or not self.attack.player:get_pos() then
print("stop attacking")
self.state = "stand"
self:set_animation("stand")
return
@ -1194,7 +1189,7 @@ function mobs:register_mob(name, def)
-- remove mob when out of range unless tamed
if mobs.remove == true and self.remove_ok and not self.tamed then
print ("REMOVED", self.remove_ok, self.name)
minetest.log("action", "[mobs] Mob removed (out of range): " .. tostring(self.remove_ok) .." ".. self.name)
self.object:remove()
end
self.remove_ok = true
@ -1209,7 +1204,6 @@ function mobs:register_mob(name, def)
tmp[_] = self[_]
end
end
-- print('===== '..self.name..'\n'.. dump(tmp)..'\n=====\n')
return minetest.serialize(tmp)
end,
@ -1352,7 +1346,7 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, inter
-- spawn mob half block higher
pos.y = pos.y - 0.5
minetest.add_entity(pos, name)
--print ("Spawned "..name.." at "..minetest.pos_to_string(pos).." on "..node.name.." near "..neighbors[1])
minetest.log("action", "[mobs] Spawned "..name.." at "..minetest.pos_to_string(pos).." on "..node.name.." near "..neighbors[1])
end
})
@ -1492,7 +1486,7 @@ function mobs:register_arrow(name, def)
self.lastpos = (self.lastpos or pos)
minetest.add_item(self.lastpos, self.object:get_luaentity().name)
end
self.object:remove() ; -- print ("hit node")
self.object:remove()
return
end
@ -1502,14 +1496,14 @@ function mobs:register_arrow(name, def)
if self.hit_player
and player:is_player() then
self.hit_player(self, player)
self.object:remove() ; -- print ("hit player")
self.object:remove()
return
end
if self.hit_mob
and player:get_luaentity().name ~= self.object:get_luaentity().name
and player:get_luaentity().name ~= "__builtin:item" then
self.hit_mob(self, player)
self.object:remove() ; -- print ("hit mob")
self.object:remove()
return
end
end

View File

@ -8,29 +8,29 @@ if minetest.settings:get_bool("testing_enable") then
for i = 1, 10000 do
dump({x=0,y=50,z=100})
end
print(string.format("10000 iterations with dump({x=0,y=50,z=100}) took %.2fms", (os.clock() - t1) * 1000))
minetest.log("action", string.format("10000 iterations with dump({x=0,y=50,z=100}) took %.2fms", (os.clock() - t1) * 1000))
local t2 = os.clock()
for i = 1, 10000 do
tostring({x=0,y=50,z=100})
end
print(string.format("10000 iterations with tostring({x=0,y=50,z=100}) took %.2fms", (os.clock() - t2) * 1000))
minetest.log("action", string.format("10000 iterations with tostring({x=0,y=50,z=100}) took %.2fms", (os.clock() - t2) * 1000))
local t3 = os.clock()
for i = 1, 10000 do
minetest.serialize({x=0,y=50,z=100})
end
print(string.format("10000 iterations with minetest.serialize({x=0,y=50,z=100}) took %.2fms", (os.clock() - t3) * 1000))
minetest.log("action", string.format("10000 iterations with minetest.serialize({x=0,y=50,z=100}) took %.2fms", (os.clock() - t3) * 1000))
local t4 = os.clock()
for i = 1, 10000 do
default.dumpvec({x=0,y=50,z=100})
end
print(string.format("10000 iterations with(custom function) default.dumpvec({x=0,y=50,z=100}) took %.2fms", (os.clock() - t4) * 1000))
minetest.log("action", string.format("10000 iterations with(custom function) default.dumpvec({x=0,y=50,z=100}) took %.2fms", (os.clock() - t4) * 1000))
local t5 = os.clock()
for i = 1, 10000 do
minetest.hash_node_position({x=0,y=50,z=100})
end
print(string.format("10000 iterations with minetest.hash_node_position({x=0,y=50,z=100}) took %.2fms", (os.clock() - t5) * 1000))
end
minetest.log("action", string.format("10000 iterations with minetest.hash_node_position({x=0,y=50,z=100}) took %.2fms", (os.clock() - t5) * 1000))
end

View File

@ -380,7 +380,7 @@ function village.spawn_village(pos, pr)
local t1 = os.clock()
village.spawn_road(pos, houses, built, roads, depth, pr)
print(string.format("Took %.2fms to spawn village", (os.clock() - t1) * 1000))
minetest.log("action", string.format("[village] Took %.2fms to generate village", (os.clock() - t1) * 1000))
local function connects(pos, nextpos)
local hnp = minetest.hash_node_position(nextpos)

View File

@ -85,7 +85,7 @@ minetest.register_lbm(
if nearest.dist > village.min_spawn_dist then
if vector.distance(spawn_pos, pos) > spawn_radius then
minetest.log("Spawning a Grassland village at " .. "(" .. pos.x
minetest.log("action", "[village] Spawning a Grassland village at " .. "(" .. pos.x
.. ", " .. pos.y .. ", " .. pos.z .. ")")
minetest.after(
@ -94,10 +94,10 @@ minetest.register_lbm(
village.spawn_village(pos, pr)
end)
else
minetest.log("Cannot spawn village, too near the static spawnpoint")
minetest.log("action", "[village] Cannot spawn village, too near the static spawnpoint")
end
else
minetest.log("Cannot spawn village, too near another village")
minetest.log("action", "[village] Cannot spawn village, too near another village")
end
end
end,