Improve log messages (#422)
- Add log messages wherever required/useful - Remove unnecessary log messages and print statements - Convert print statements to minetest.log - Fix incorrect log level for some messages - Trivial code-style fixes
This commit is contained in:
parent
21e7daa183
commit
5eb5d3311a
18 changed files with 71 additions and 49 deletions
|
@ -50,8 +50,6 @@ function ctf_alloc.set_all()
|
|||
return a.score > b.score
|
||||
end)
|
||||
|
||||
minetest.log("warning", dump(players))
|
||||
|
||||
local to_red = math.random(2) == 2
|
||||
for _, spair in pairs(players) do
|
||||
local player = spair.player
|
||||
|
|
|
@ -99,6 +99,7 @@ ctf.register_on_killedplayer(function(victim, killer)
|
|||
bountied_player = nil
|
||||
|
||||
local msg = killer .. " has killed " .. victim .. " and received the prize!"
|
||||
minetest.log("action", msg)
|
||||
minetest.chat_send_all(msg)
|
||||
hud_score.new(killer, {
|
||||
name = "ctf_bounty:prize",
|
||||
|
@ -118,6 +119,7 @@ minetest.register_chatcommand("place_bounty", {
|
|||
end
|
||||
|
||||
bounty_player(target)
|
||||
minetest.log("action", name .. " places bounty on " .. target)
|
||||
return true, "Put bounty on " .. target
|
||||
end
|
||||
})
|
||||
|
|
|
@ -114,7 +114,7 @@ function ctf_map.place_outer_barrier(center, r, h)
|
|||
minp.y = center.y - h / 2
|
||||
maxp.y = center.y + h / 2
|
||||
|
||||
print("Loading data into LVM")
|
||||
minetest.log("action", "Map maker: Loading data into LVM")
|
||||
|
||||
local vm = minetest.get_voxel_manip()
|
||||
local emin, emax = vm:read_from_map(minp, maxp)
|
||||
|
@ -124,7 +124,7 @@ function ctf_map.place_outer_barrier(center, r, h)
|
|||
}
|
||||
local data = vm:get_data()
|
||||
|
||||
print("Placing left wall")
|
||||
minetest.log("action", "Map maker: Placing left wall")
|
||||
|
||||
-- Left
|
||||
do
|
||||
|
@ -141,7 +141,7 @@ function ctf_map.place_outer_barrier(center, r, h)
|
|||
end
|
||||
end
|
||||
|
||||
print("Placing right wall")
|
||||
minetest.log("action", "Map maker: Placing right wall")
|
||||
|
||||
-- Right
|
||||
do
|
||||
|
@ -158,7 +158,7 @@ function ctf_map.place_outer_barrier(center, r, h)
|
|||
end
|
||||
end
|
||||
|
||||
print("Placing front wall")
|
||||
minetest.log("action", "Map maker: Placing front wall")
|
||||
|
||||
-- Front
|
||||
do
|
||||
|
@ -175,7 +175,7 @@ function ctf_map.place_outer_barrier(center, r, h)
|
|||
end
|
||||
end
|
||||
|
||||
print("Placing back wall")
|
||||
minetest.log("action", "Map maker: Placing back wall")
|
||||
|
||||
-- Back
|
||||
do
|
||||
|
@ -192,7 +192,7 @@ function ctf_map.place_outer_barrier(center, r, h)
|
|||
end
|
||||
end
|
||||
|
||||
print("Placing bedrock")
|
||||
minetest.log("action", "Map maker: Placing bedrock")
|
||||
|
||||
-- Bedrock
|
||||
do
|
||||
|
@ -204,7 +204,7 @@ function ctf_map.place_outer_barrier(center, r, h)
|
|||
end
|
||||
end
|
||||
|
||||
print("Placing ceiling")
|
||||
minetest.log("action", "Map maker: Placing ceiling")
|
||||
|
||||
-- Ceiling
|
||||
do
|
||||
|
@ -216,7 +216,7 @@ function ctf_map.place_outer_barrier(center, r, h)
|
|||
end
|
||||
end
|
||||
|
||||
print("Writing to engine!")
|
||||
minetest.log("action", "Map maker: Writing to engine!")
|
||||
|
||||
vm:set_data(data)
|
||||
vm:write_to_map(data)
|
||||
|
|
|
@ -152,6 +152,7 @@ minetest.register_chatcommand("maps", {
|
|||
send_irc_catalog(name, idx or 1)
|
||||
end
|
||||
|
||||
minetest.log("action", name .. " views the map catalog")
|
||||
return true
|
||||
end
|
||||
})
|
||||
|
|
|
@ -72,6 +72,7 @@ minetest.register_chatcommand("set_next", {
|
|||
local idx, map = ctf_map.get_idx_and_map(param)
|
||||
if idx then
|
||||
next_idx = idx
|
||||
minetest.log("action", name .. " selected '" .. map.name .. "' as next map")
|
||||
return true, "Selected " .. map.name
|
||||
else
|
||||
return false, "Couldn't find any matches"
|
||||
|
@ -80,7 +81,7 @@ minetest.register_chatcommand("set_next", {
|
|||
})
|
||||
|
||||
local function load_map_meta(idx, path)
|
||||
print("load_map_meta: Loading map meta from \"" .. path .. "\"")
|
||||
minetest.log("info", "load_map_meta: Loading map meta from \"" .. path .. "\"")
|
||||
local conf_path = mapdir .. path .. ".conf"
|
||||
local offset = vector.new(600 * idx, 0, 0)
|
||||
local meta = Settings(conf_path)
|
||||
|
@ -137,6 +138,7 @@ local function load_map_meta(idx, path)
|
|||
|
||||
-- Read custom chest zones from config
|
||||
i = 1
|
||||
minetest.log("info", "Parsing chest zones of " .. map.name .. "...")
|
||||
while meta:get("chests." .. i .. ".from") do
|
||||
local from = minetest.string_to_pos(meta:get("chests." .. i .. ".from"))
|
||||
local to = minetest.string_to_pos(meta:get("chests." .. i .. ".to"))
|
||||
|
@ -149,7 +151,7 @@ local function load_map_meta(idx, path)
|
|||
n = tonumber(meta:get("chests." .. i .. ".n") or "23"),
|
||||
}
|
||||
|
||||
minetest.log("warning", dump(map.chests[i]))
|
||||
minetest.log("info", dump(map.chests[i]))
|
||||
|
||||
i = i + 1
|
||||
end
|
||||
|
@ -252,7 +254,7 @@ local function place_map(map)
|
|||
|
||||
local seed = minetest.get_mapgen_setting("seed")
|
||||
for _, chestzone in pairs(ctf_map.map.chests) do
|
||||
minetest.log("warning", "Placing " .. chestzone.n .. " chests from " ..
|
||||
minetest.log("info", "Placing " .. chestzone.n .. " chests from " ..
|
||||
minetest.pos_to_string(chestzone.from) .. " to "..
|
||||
minetest.pos_to_string(chestzone.to))
|
||||
place_chests(chestzone.from, chestzone.to, seed, chestzone.n)
|
||||
|
@ -340,7 +342,7 @@ ctf_match.register_on_new_match(function()
|
|||
end
|
||||
|
||||
if is_valid then
|
||||
minetest.log("info",
|
||||
minetest.log("action",
|
||||
"ctf_map: Registering treasure - " .. def[1])
|
||||
treasurer.register_treasure(def[1], def[2], def[3], def[4])
|
||||
end
|
||||
|
@ -362,7 +364,7 @@ function ctf_match.create_teams()
|
|||
local flag = table.copy(value.pos)
|
||||
|
||||
if name and color and flag then
|
||||
print(" - creating " .. key)
|
||||
minetest.log("action", "Creating team " .. key)
|
||||
ctf.team({
|
||||
name = name,
|
||||
color = color,
|
||||
|
@ -375,7 +377,7 @@ function ctf_match.create_teams()
|
|||
ctf_flag.assert_flag(flag)
|
||||
end)
|
||||
else
|
||||
minetest.log("error", " - Failed to create " .. key)
|
||||
minetest.log("error", "Failed to create team " .. key)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -42,11 +42,13 @@ local function add_marker(name, tname, pos, str)
|
|||
if tplayer then
|
||||
teams[tname].players[pname] = tplayer:hud_add({
|
||||
hud_elem_type = "waypoint",
|
||||
name = str,
|
||||
number = ctf.flag_colors[team.data.color],
|
||||
world_pos = pos
|
||||
name = str,
|
||||
number = ctf.flag_colors[team.data.color],
|
||||
world_pos = pos
|
||||
})
|
||||
end
|
||||
minetest.log("action", name .. " placed a marker at " ..
|
||||
minetest.pos_to_string(pos) .. ": '" .. str .. "'")
|
||||
minetest.chat_send_player(pname,
|
||||
msg("Player " .. name .. " placed a marker!"))
|
||||
end
|
||||
|
@ -68,7 +70,7 @@ end)
|
|||
minetest.register_chatcommand("m", {
|
||||
param = "[Optional description]",
|
||||
description = "Allows players to share the location of where " ..
|
||||
"they're looking at with their team-mates.",
|
||||
"they're looking at with their team-mates.",
|
||||
privs = { interact = true },
|
||||
func = function(name, param)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
|
@ -79,7 +81,7 @@ minetest.register_chatcommand("m", {
|
|||
-- Calculate marker pos
|
||||
local dir = player:get_look_dir()
|
||||
local p1 = vector.add(player:get_pos(),
|
||||
{ x = 0, y = player:get_properties().eye_height, z = 0})
|
||||
{ x = 0, y = player:get_properties().eye_height, z = 0 })
|
||||
p1 = vector.add(p1, dir)
|
||||
local p2 = vector.add(p1, vector.multiply(dir, 500))
|
||||
local pointed = minetest.raycast(p1, p2, true, true):next()
|
||||
|
|
|
@ -9,6 +9,7 @@ minetest.register_chatcommand("ctf_next", {
|
|||
},
|
||||
func = function(name, param)
|
||||
ctf_match.next()
|
||||
minetest.log("action", name .. " ran /ctf_next")
|
||||
end
|
||||
})
|
||||
|
||||
|
@ -18,7 +19,8 @@ minetest.register_chatcommand("ctf_start", {
|
|||
ctf_match = true
|
||||
},
|
||||
func = function(name, param)
|
||||
ctf_match.build_timer = 0.01
|
||||
ctf_match.build_timer = 0.01
|
||||
minetest.log("action", name .. " ran /ctf_start")
|
||||
end
|
||||
})
|
||||
|
||||
|
@ -58,6 +60,7 @@ minetest.register_chatcommand("ctf_queue_restart", {
|
|||
func = function(name, param)
|
||||
restart_on_next_match = true
|
||||
restart_on_next_match_by = name
|
||||
minetest.log("action", name .. " queued a restart")
|
||||
return true, "Restart queued."
|
||||
end
|
||||
})
|
||||
|
@ -69,6 +72,7 @@ minetest.register_chatcommand("ctf_unqueue_restart", {
|
|||
},
|
||||
func = function(name, param)
|
||||
restart_on_next_match = false
|
||||
minetest.log("action", name .. " un-queued a restart")
|
||||
return true, "Restart cancelled."
|
||||
end
|
||||
})
|
||||
|
|
|
@ -54,7 +54,6 @@ local function update(player, settings)
|
|||
|
||||
if settings.type == TYPE_BUILTIN then
|
||||
remove_entity_tag(player)
|
||||
print(dump(settings.color))
|
||||
player:set_nametag_attributes({
|
||||
color = settings.color
|
||||
})
|
||||
|
|
|
@ -287,11 +287,13 @@ minetest.register_chatcommand("r", {
|
|||
param = param:trim()
|
||||
if ctf_stats.players[param] then
|
||||
target = param
|
||||
minetest.log("action", name .. " ran /r " .. param)
|
||||
else
|
||||
return false, "Can't find player '" .. param .. "'"
|
||||
end
|
||||
else
|
||||
target = name
|
||||
minetest.log("action", name .. " ran /r")
|
||||
end
|
||||
return return_as_chat_result(name, target)
|
||||
end
|
||||
|
@ -306,11 +308,13 @@ minetest.register_chatcommand("rankings", {
|
|||
param = param:trim()
|
||||
if ctf_stats.players[param] then
|
||||
target = param
|
||||
minetest.log("action", name .. " ran /rankings " .. param)
|
||||
else
|
||||
return false, "Can't find player '" .. param .. "'"
|
||||
end
|
||||
else
|
||||
target = name
|
||||
minetest.log("action", name .. " ran /rankings")
|
||||
end
|
||||
|
||||
if not minetest.get_player_by_name(name) then
|
||||
|
@ -359,6 +363,13 @@ minetest.register_chatcommand("reset_rankings", {
|
|||
|
||||
ctf_stats.players[reset_name] = nil
|
||||
ctf_stats.player(reset_name)
|
||||
|
||||
if reset_name == name then
|
||||
minetest.log("action", name .. " reset their rankings")
|
||||
else
|
||||
minetest.log("action", name .. " reset rankings of " .. reset_name)
|
||||
end
|
||||
|
||||
return true, "Successfully reset the stats and ranking of " .. reset_name
|
||||
end
|
||||
})
|
||||
|
@ -386,6 +397,7 @@ minetest.register_chatcommand("transfer_rankings", {
|
|||
ctf_stats.players[dest] = ctf_stats.players[src]
|
||||
ctf_stats.players[src] = nil
|
||||
|
||||
minetest.log("action", name .. " transferred stats of " .. src .. " to " .. dest)
|
||||
return true, "Stats of '" .. src .. "' have been transferred to '" .. dest .. "'."
|
||||
end
|
||||
})
|
||||
|
|
|
@ -346,10 +346,11 @@ end)
|
|||
minetest.register_chatcommand("summary", {
|
||||
func = function(name)
|
||||
local fs = ctf_stats.get_formspec_match_summary(ctf_stats.current,
|
||||
winner_team, winner_player, os.time() - ctf_stats.start)
|
||||
winner_team, winner_player, os.time() - ctf_stats.start)
|
||||
|
||||
fs = fs .. "button[6,7.5;4,1;b_prev;<< Previous match]"
|
||||
|
||||
minetest.log("action", name .. " requested match summary formspec")
|
||||
minetest.show_formspec(name, "ctf_stats:match_summary", fs)
|
||||
end
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue