Disable inv for now, remove debug stuff from ctf_stats

This commit is contained in:
rubenwardy 2015-11-29 23:55:27 +00:00
parent 9138ce81a9
commit ae6a5e7741
3 changed files with 19 additions and 27 deletions

View file

@ -0,0 +1 @@
ctf

View file

@ -1,3 +1,7 @@
ctf.register_on_init(function()
ctf._set("inventory", false)
end)
local fs = "size[8,8.5]" ..
"bgcolor[#080808BB;true]" ..
"background[5,5;1,1;gui_formbg.png;true]" ..
@ -39,5 +43,7 @@ fs = fs ..
"image[7,4.25;1,1;gui_hb_bg.png]"
minetest.register_on_joinplayer(function(player)
if ctf.setting("inventory") then
player:set_inventory_formspec(fs)
end
end)

View file

@ -1,7 +1,6 @@
ctf_stats = {}
function ctf_stats.load()
print("load")
local file = io.open(minetest.get_worldpath().."/ctf_stats.txt", "r")
if file then
local table = minetest.deserialize(file:read("*all"))
@ -44,7 +43,6 @@ ctf.register_on_save(function()
end)
function ctf_stats.player(name)
print("get " .. name)
local tplayer = ctf.player(name)
local player = ctf_stats.players[name]
if not player then
@ -65,8 +63,6 @@ function ctf_stats.player(name)
end
ctf.register_on_join_team(function(name, tname)
print("join team")
ctf_stats.current[tname][name] = {
kills = 0,
deaths = 0,
@ -75,56 +71,45 @@ ctf.register_on_join_team(function(name, tname)
end)
ctf_match.register_on_skip_map(function()
print("skip map")
ctf_stats.matches.skipped = ctf_stats.matches.skipped + 1
end)
ctf_match.register_on_winner(function(winner)
print("win " .. winner)
ctf_stats.matches[winner .. "_wins"] = ctf_stats.matches[winner .. "_wins"] + 1
end)
ctf_match.register_on_new_match(function()
print("new match")
-- TODO: create and show match report
print(dump(ctf_stats.matches))
print(dump(ctf_stats.current))
print(dump(ctf_stats.players))
ctf_stats.current = {
red = {},
blue = {}
}
minetest.after(3, function()
print(dump(ctf_stats.current))
end)
end)
ctf_flag.register_on_pick_up(function(name, flag)
print("pick up")
local main, match = ctf_stats.player(name)
if main and match then
main.attempts = main.attempts + 1
match.attempts = match.attempts + 1
end
end)
ctf_flag.register_on_precapture(function(name, flag)
print("capture")
local tplayer = ctf.player(name)
local main, match = ctf_stats.player(name)
if main then
main[tplayer.team .. "_wins"] = main[tplayer.team .. "_wins"] + 1
end
return true
end)
minetest.register_on_dieplayer(function(player)
print("die")
local main, match = ctf_stats.player(player:get_player_name())
if main and match then
main.deaths = main.deaths + 1
match.deaths = match.deaths + 1
end
end)
ctf_stats.load()