Replace print with minetest.log

This commit is contained in:
Wuzzy 2020-03-30 23:09:30 +02:00
parent 1027aa0f89
commit 21b8f831ee
18 changed files with 49 additions and 85 deletions

View File

@ -43,13 +43,13 @@ function awards.tbv(tb,value,default)
if not value then
value = "[NULL]"
end
print("[ERROR] awards.tbv - table '"..value.."' is null, or not a table! Dump: "..dump(tb))
minetest.log("error", "awards.tbv - table '"..value.."' is null, or not a table! Dump: "..dump(tb))
return
end
if not value then
print("[ERROR] awards.tbv was not used correctly!")
print("Value: '"..dump(value).."'")
print("Dump:"..dump(tb))
minetest.log("error", "awards.tbv was not used correctly!")
minetest.log("error", "Value: '"..dump(value).."'")
minetest.log("error", "Dump:"..dump(tb))
return
end
if not tb[value] then
@ -191,7 +191,7 @@ function awards.give_achievement(name,award)
end
-- record this in the log
print(name.." Has unlocked"..title..".")
minetest.log("action", name.." Has unlocked"..title..".")
-- save playertable
awards.save()

View File

@ -17,7 +17,7 @@ minetest.register_on_dignode(function(pos, oldnode, digger)
end
local nodedug = string.split(oldnode.name, ":")
if #nodedug ~= 2 then
print(oldnode.name.." is in wrong format!")
minetest.log("action", oldnode.name.." is in wrong format!")
return
end
local mod=nodedug[1]
@ -33,7 +33,7 @@ minetest.register_on_dignode(function(pos, oldnode, digger)
-- Increment counder
awards.players[playern].count[mod][item]=awards.players[playern].count[mod][item]+1
print(" - "..mod..":"..item.." 's count is now "..(awards.players[playern].count[mod][item]))
minetest.log("action", " - "..mod..":"..item.." 's count is now "..(awards.players[playern].count[mod][item]))
-- Run callbacks and triggers
local player=digger
@ -48,7 +48,7 @@ minetest.register_on_dignode(function(pos, oldnode, digger)
-- Handle table trigger
if not awards.onDig[i].node or not awards.onDig[i].target or not awards.onDig[i].award then
-- table running failed!
print("[ERROR] awards - onDig trigger "..i.." is invalid!")
minetest.log("error", "awards - onDig trigger "..i.." is invalid!")
else
-- run the table
local tnodedug = string.split(awards.onDig[i].node, ":")
@ -74,7 +74,7 @@ minetest.register_on_placenode(function(pos,node,digger)
end
local nodedug = string.split(node.name, ":")
if #nodedug ~= 2 then
print(oldnode.name.." is in wrong format!")
minetest.log("action", oldnode.name.." is in wrong format!")
return
end
local mod=nodedug[1]
@ -91,7 +91,7 @@ minetest.register_on_placenode(function(pos,node,digger)
-- Increment counder
awards.players[playern].place[mod][item] = awards.players[playern].place[mod][item]+1
print(" - "..mod..":"..item.." 's place count is now "..(awards.players[playern].place[mod][item]))
minetest.log("action", " - "..mod..":"..item.." 's place count is now "..(awards.players[playern].place[mod][item]))
-- Run callbacks and triggers
local player = digger
@ -105,7 +105,7 @@ minetest.register_on_placenode(function(pos,node,digger)
-- Handle table trigger
if not awards.onPlace[i].node or not awards.onPlace[i].target or not awards.onPlace[i].award then
-- table running failed!
print("[ERROR] awards - onPlace trigger "..i.." is invalid!")
minetest.log("error", "awards - onPlace trigger "..i.." is invalid!")
else
-- run the table
local tnodedug = string.split(awards.onPlace[i].node, ":")
@ -148,7 +148,7 @@ minetest.register_on_dieplayer(function(player)
-- handle table here
if not awards.onDeath[i].target or not awards.onDeath[i].award then
-- table running failed!
print("[ERROR] awards - onDeath trigger "..i.." is invalid!")
minetest.log("error", "awards - onDeath trigger "..i.." is invalid!")
else
-- run the table
if not data.deaths then

View File

@ -160,7 +160,7 @@ minetest.register_abm({
srcstack:take_item()
inv:set_stack("src", 1, srcstack)
--else
--print("Could not insert '"..cooked.item.."'")
--minetest.log("action", "Could not insert '"..cooked.item.."'")
end
meta:set_string("src_time", 0)
end

View File

@ -55,4 +55,4 @@ plantslib:spawn_on_surfaces({
minetest.register_alias("bushes:basket_pies", "bushes:basket_strawberry")
print(S("[Bushes] Loaded."))
minetest.log("action", S("[Bushes] Loaded."))

View File

@ -28,9 +28,9 @@ minetest.after(0, function()
on_put = function(inv, listname, index, stack, player)
end,
on_take = function(inv, listname, index, stack, player)
print(player:get_player_name().." takes item from creative inventory; listname="..dump(listname)..", index="..dump(index)..", stack="..dump(stack))
minetest.log("action", player:get_player_name().." takes item from creative inventory; listname="..dump(listname)..", index="..dump(index)..", stack="..dump(stack))
if stack then
print("stack:get_name()="..dump(stack:get_name())..", stack:get_count()="..dump(stack:get_count()))
minetest.log("action", "stack:get_name()="..dump(stack:get_name())..", stack:get_count()="..dump(stack:get_count()))
end
end,
})
@ -47,7 +47,7 @@ minetest.after(0, function()
inv:add_item("main", ItemStack(itemstring))
end
creative_inventory.creative_inventory_size = #creative_list
print("creative inventory size: "..dump(creative_inventory.creative_inventory_size))
minetest.log("action", "creative inventory size: "..dump(creative_inventory.creative_inventory_size))
end)
-- Create the trash field

View File

@ -26,7 +26,7 @@ function crafter.get_craft_result(data)
r=crafter._check_craft(data,w,craft)
if r ~= nil then
if crafter.debug then
print("Craft found, returning "..dump(r.item))
minetest.log("info", "Craft found, returning "..dump(r.item))
end
return r
end
@ -41,14 +41,14 @@ function crafter._check_craft(data,w,c)
for j=1,w-c._w+1 do
local p=(i-1)*w+j
if crafter.debug then
print("Checking data.items["..dump(i).."]["..dump(j).."]("..dump(p)..")="..dump(data.items[p]:get_name()).." vs craft.recipe[1][1]="..dump(c.recipe[1][1]))
minetest.log("info", "Checking data.items["..dump(i).."]["..dump(j).."]("..dump(p)..")="..dump(data.items[p]:get_name()).." vs craft.recipe[1][1]="..dump(c.recipe[1][1]))
end
if data.items[p]:get_name() == c.recipe[1][1] then
for m=1,c._h do
for n=1,c._w do
local q=(i+m-1-1)*w+j+n-1
if crafter.debug then
print(" Checking data.items["..dump(i+m-1).."]["..dump(j+n-1).."]("..dump(q)..")="..dump(data.items[q]:get_name())..
minetest.log("info", " Checking data.items["..dump(i+m-1).."]["..dump(j+n-1).."]("..dump(q)..")="..dump(data.items[q]:get_name())..
" vs craft.recipe["..dump(m).."]["..dump(n).."]="..dump(c.recipe[m][n]))
end
if c.recipe[m][n] ~= data.items[q]:get_name() then
@ -62,7 +62,7 @@ function crafter._check_craft(data,w,c)
for n=j+c._w,w do
local q=(m-1)*w+n
if crafter.debug then
print(" Checking right data.items["..dump(m).."]["..dump(n).."]("..dump(q)..")="..dump(data.items[q]:get_name()))
minetest.log("info", " Checking right data.items["..dump(m).."]["..dump(n).."]("..dump(q)..")="..dump(data.items[q]:get_name()))
end
if data.items[q]:get_name() ~= "" then
return nil
@ -74,7 +74,7 @@ function crafter._check_craft(data,w,c)
for n=1,j-1 do
local q=(m-1)*w+n
if crafter.debug then
print(" Checking left data.items["..dump(m).."]["..dump(n).."]("..dump(q)..")="..dump(data.items[q]:get_name()))
minetest.log("info", " Checking left data.items["..dump(m).."]["..dump(n).."]("..dump(q)..")="..dump(data.items[q]:get_name()))
end
if data.items[q]:get_name() ~= "" then
return nil
@ -86,7 +86,7 @@ function crafter._check_craft(data,w,c)
for n=j,j+c._w do
local q=(m-1)*w+n
if crafter.debug then
print(" Checking bottom data.items["..dump(m).."]["..dump(n).."]("..dump(q)..")="..dump(data.items[q]:get_name()))
minetest.log("info", " Checking bottom data.items["..dump(m).."]["..dump(n).."]("..dump(q)..")="..dump(data.items[q]:get_name()))
end
if data.items[q]:get_name() ~= "" then
return nil
@ -94,12 +94,12 @@ function crafter._check_craft(data,w,c)
end
end
if crafter.debug then
print("Craft found! "..c.output)
minetest.log("info", "Craft found! "..c.output)
end
return {item=ItemStack(c.output),time=1}
elseif data.items[p] ~= nil and data.items[p]:get_name() ~= "" then
if crafter.debug then
print("Invalid data item "..dump(data.items[p]:get_name()))
minetest.log("info", "Invalid data item "..dump(data.items[p]:get_name()))
end
return nil
end

View File

@ -623,7 +623,6 @@ minetest.register_node("default:sign_wall", {
meta:set_string("infotext", "\"\"")
end,
on_receive_fields = function(pos, formname, fields, sender)
--print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields))
local meta = minetest.get_meta(pos)
meta:set_string("formspec", "field[text;;${text}]")
if minetest.is_protected(pos, sender:get_player_name()) then
@ -707,30 +706,4 @@ minetest.register_craft({
output = "default:stone",
recipe = "default:stone_macadam",
cooktime = 8,
})
--
-- Global callbacks
--
-- Global environment step function
function on_step(dtime)
-- print("on_step")
end
minetest.register_globalstep(on_step)
function on_placenode(p, node)
--print("on_placenode")
end
minetest.register_on_placenode(on_placenode)
function on_dignode(p, node)
--print("on_dignode")
end
minetest.register_on_dignode(on_dignode)
function on_punchnode(p, node)
end
minetest.register_on_punchnode(on_punchnode)
-- END
})

View File

@ -48,8 +48,8 @@ function fire.update_sounds_around(pos)
local p0, p1 = fire.get_area_p0p1(pos)
local cp = {x=(p0.x+p1.x)/2, y=(p0.y+p1.y)/2, z=(p0.z+p1.z)/2}
local flames_p = minetest.find_nodes_in_area(p0, p1, {"fire:basic_flame"})
--print("number of flames at "..minetest.pos_to_string(p0).."/"
-- ..minetest.pos_to_string(p1)..": "..#flames_p)
minetest.log("verbose", "number of flames at "..minetest.pos_to_string(p0).."/"
..minetest.pos_to_string(p1)..": "..#flames_p)
local should_have_sound = (#flames_p > 0)
local wanted_sound = nil
if #flames_p >= 9 then
@ -81,12 +81,12 @@ function fire.update_sounds_around(pos)
end
function fire.on_flame_add_at(pos)
--print("flame added at "..minetest.pos_to_string(pos))
minetest.log("info", "flame added at "..minetest.pos_to_string(pos))
fire.update_sounds_around(pos)
end
function fire.on_flame_remove_at(pos)
--print("flame removed at "..minetest.pos_to_string(pos))
minetets.log("info", "flame removed at "..minetest.pos_to_string(pos))
fire.update_sounds_around(pos)
end

View File

@ -475,5 +475,3 @@ minetest.register_alias("flowers:potted_cotton_plant", "flowers:potted_dandelion
minetest.register_alias("flowers:cotton", "farming:string")
minetest.register_alias("flowers:cotton_wad", "farming:string")
minetest.register_alias("sunflower:sunflower", "flowers:sunflower")
print(S("[Flowers] Loaded."))

View File

@ -213,8 +213,8 @@ minetest.register_abm({
srcstack = inv:get_stack("src"..i, 1)
srcstack:take_item()
inv:set_stack("src"..i, 1, srcstack)
--else
--print("Could not insert '"..cooked.item.."'")
else
minetest.log("verbose", "[furnace] Could not insert '"..cooked.item.."'")
end
meta:set_string("src_time"..i, 0)
end

View File

@ -140,5 +140,3 @@ for i in ipairs(grasses_list) do
grow_nodes = {"default:dirt_with_grass", "default:sand", "default:desert_sand"}
})
end
print("[Junglegrass] Loaded.")

View File

@ -8,7 +8,7 @@ local textures_config = worldpath.."/player_skins_db.txt"
if io.open(textures_config, "r") ~= nil then
io.input(textures_config)
skins_cfg = io.read("*all")
print(dump(skins_cfg))
minetest.log("verbose", dump(skins_cfg))
mf_skins_table = minetest.deserialize(skins_cfg)
io.close()
end
@ -20,7 +20,7 @@ else
end
local save_skins = function()
print(dump(mf_skins_table))
minetest.log("verbose", dump(mf_skins_table))
local file = io.open(textures_config, "w")
file:write(minetest.serialize(mf_skins_table))
io.close()
@ -32,7 +32,7 @@ minetest.register_on_joinplayer(
local skin_name = "skin_"..pn
local skin_gender = { "player_male.png" }
print("Skin for "..pn.." was set to "..dump(mf_skins_table[skin_name]))
minetest.log("action", "Skin for "..pn.." was set to "..dump(mf_skins_table[skin_name]))
if mf_skins_table[skin_name] == "f" then
skin_gender = { "player_female.png" }
end

View File

@ -224,7 +224,7 @@ minetest.register_abm({
-- take stuff from "src" list
inv:set_stack("src", 1, aftercooked.items[1])
else
print("Could not insert '"..cooked.item:to_string().."'")
minetest.log("verbose", "[oven] Could not insert '"..cooked.item:to_string().."'")
end
meta:set_string("src_time", 0)
end

View File

@ -445,7 +445,7 @@ dbg(string)
This is a simple debug output function which takes one string parameter. It
just checks if DEBUG is true and outputs the phrase "[Plantlife] " followed by
the supplied string, via the print() function, if so.
the supplied string.
=====
plantslib:generate_tree(pos, treemodel)

View File

@ -42,7 +42,6 @@ local DEBUG = false --... except if you want to spam the console with debugging
function plantslib:dbg(msg)
if DEBUG then
print("[Plantlife] "..msg)
minetest.log("verbose", "[Plantlife] "..msg)
end
end
@ -446,8 +445,8 @@ end)
-- to prevent unpopulated map areas
minetest.register_on_shutdown(function()
print("[plants_lib] Stand by, playing out the rest of the aircheck mapblock log")
print("(there are "..#plantslib.blocklist_aircheck.." entries)...")
minetest.log("verbose", "[plants_lib] Stand by, playing out the rest of the aircheck mapblock log")
minetest.log("verbose", "(there are "..#plantslib.blocklist_aircheck.." entries)...")
while true do
plantslib:generate_block_with_air_checking(0.1)
if #plantslib.blocklist_aircheck == 0 then return end
@ -455,8 +454,8 @@ minetest.register_on_shutdown(function()
end)
minetest.register_on_shutdown(function()
print("[plants_lib] Stand by, playing out the rest of the no-aircheck mapblock log")
print("(there are "..#plantslib.blocklist_aircheck.." entries)...")
minetest.log("verbose", "[plants_lib] Stand by, playing out the rest of the no-aircheck mapblock log")
minetest.log("verbose", "(there are "..#plantslib.blocklist_aircheck.." entries)...")
while true do
plantslib:generate_block_no_aircheck(0.1)
if #plantslib.blocklist_no_aircheck == 0 then return end
@ -726,10 +725,8 @@ function plantslib:get_nodedef_field(nodename, fieldname)
return minetest.registered_nodes[nodename][fieldname]
end
print("[Plants Lib] Loaded")
minetest.after(0, function()
print("[Plants Lib] Registered a total of "..(#plantslib.surfaceslist_aircheck)+(#plantslib.surfaceslist_no_aircheck).." surface types to be evaluated, spread")
print("[Plants Lib] across "..#plantslib.actionslist_aircheck.." actions with air-checking and "..#plantslib.actionslist_no_aircheck.." actions without.")
minetest.log("verbose", "[Plants Lib] Registered a total of "..(#plantslib.surfaceslist_aircheck)+(#plantslib.surfaceslist_no_aircheck).." surface types to be evaluated, spread")
minetest.log("verbose", "[Plants Lib] across "..#plantslib.actionslist_aircheck.." actions with air-checking and "..#plantslib.actionslist_no_aircheck.." actions without.")
end)

View File

@ -99,5 +99,3 @@ plantslib:grow_plants({
verticals_list = walls_list,
ground_nodes = {"default:dirt_with_grass"}
})
print(S("[Poison Ivy] Loaded."))

View File

@ -334,7 +334,7 @@ minetest.register_entity(
burn = function(self)
local hp = self.object:get_hp() - BURN_DAMAGE__HP
self.object:set_hp(hp)
print("DEBUG - bag HP = "..hp)
minetest.log("verbose", "bag HP = "..hp)
if hp <= 0 then
return self:remove()
end

View File

@ -103,8 +103,8 @@ minetest.register_abm({
local was_active = false
local consume = false
print("Fuel time: "..dump(meta:get_float("fuel_time")))
print("Fuel totaltime: "..dump(meta:get_float("fuel_totaltime")))
minetest.log("verbose", "Fuel time: "..dump(meta:get_float("fuel_time")))
minetest.log("verbose", "Fuel totaltime: "..dump(meta:get_float("fuel_totaltime")))
if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
was_active = true
@ -120,13 +120,13 @@ minetest.register_abm({
for i=1,4 do
srcstack = inv:get_stack("src", i)
if not srcstack:is_empty() then
print("Removing "..srcstack:get_name())
minetest.log("verbose", "Removing "..srcstack:get_name())
srcstack:take_item(1)
inv:set_stack("src", i, srcstack)
end
end
else
print("Could not insert '"..cooked.item:to_string().."'")
minetest.log("verbose", "Could not insert '"..cooked.item:to_string().."'")
end
meta:set_string("src_time", 0)
end