arena_lib-cd2025/debug_utilities.lua

68 lines
2.5 KiB
Lua
Raw Normal View History

2020-04-02 12:45:50 +02:00
---
--- Link these functions to your mod through some commands, ie. /yourmod info arena_name
---
local S = minetest.get_translator("arena_lib")
2020-04-02 12:45:50 +02:00
2020-04-15 13:14:30 +02:00
function arena_lib.print_arenas(sender, mod)
2020-04-02 12:45:50 +02:00
local n = 0
2020-04-15 13:14:30 +02:00
for id, arena in pairs(arena_lib.mods[mod].arenas) do
2020-04-02 12:45:50 +02:00
n = n+1
minetest.chat_send_player(sender, "ID: " .. id .. ", " .. S("name: ") .. arena.name )
2020-04-02 12:45:50 +02:00
end
minetest.chat_send_player(sender, S("Total arenas: ") .. n )
2020-04-02 12:45:50 +02:00
end
2020-04-15 15:17:12 +02:00
function arena_lib.print_arena_info(sender, mod, arena_name)
local arena_ID, arena = arena_lib.get_arena_by_name(mod, arena_name)
if arena == nil then minetest.chat_send_player(sender, minetest.colorize("#e6482e", S("[!] This arena doesn't exist!"))) return end
2020-04-02 12:45:50 +02:00
local p_count = 0
local names = ""
for pl, stats in pairs(arena.players) do
p_count = p_count +1
names = names .. " " .. pl
end
local spawners_count = 0
local spawners_pos = ""
for spawn_id, spawn_pos in pairs(arena.spawn_points) do
spawners_count = spawners_count + 1
spawners_pos = spawners_pos .. " " .. minetest.pos_to_string(spawn_pos)
end
2020-04-03 19:04:37 +02:00
minetest.chat_send_player(sender, [[
]] .. S("Name: ") .. minetest.colorize("#eea160", arena_name ) .. [[
2020-04-02 12:45:50 +02:00
]] .. "ID: " .. arena_ID .. [[
]] .. S("Enabled: ") .. tostring(arena.enabled) .. [[
]] .. S("Players required: ") .. arena.min_players .. [[
]] .. S("Players supported: ") .. arena.max_players .. [[
]] .. S("Players inside: ") .. p_count .. " ( ".. names .. " )" .. [[
]] .. S("Kills to win: ") .. arena.kill_cap .. [[
]] .. S("In queue: ") .. tostring(arena.in_queue) .. [[
]] .. S("Loading: ") .. tostring(arena.in_loading) .. [[
]] .. S("In game: ") .. tostring(arena.in_game) .. [[
]] .. S("Celebrating: ") .. tostring(arena.in_celebration) .. [[
]] .. S("Spawn points: ") .. spawners_count .. " ( " .. spawners_pos .. " )" )
2020-04-02 12:45:50 +02:00
end
2020-04-15 15:17:12 +02:00
function arena_lib.print_arena_stats(sender, mod, arena_name)
2020-04-02 12:45:50 +02:00
2020-04-15 15:17:12 +02:00
local arena_ID, arena = arena_lib.get_arena_by_name(mod, arena_name)
if arena == nil then minetest.chat_send_player(sender, minetest.colorize("#e6482e", S("[!] This arena doesn't exist!"))) return end
2020-04-02 12:45:50 +02:00
if not arena.in_game and not arena.in_celebration then minetest.chat_send_player(name, minetest.colorize("#e6482e", S("[!] No ongoing game!"))) return end
2020-04-02 12:45:50 +02:00
for pl, stats in pairs(arena.players) do
minetest.chat_send_player(sender, S("Player: ") .. pl .. S(", kills: ") .. stats.kills .. S(", deaths: ") .. stats.deaths .. S(", killstreak: ") .. stats.killstreak)
2020-04-02 12:45:50 +02:00
end
end