Disable inv for now, remove debug stuff from ctf_stats
This commit is contained in:
parent
9138ce81a9
commit
ae6a5e7741
3 changed files with 19 additions and 27 deletions
1
mods/ctf_inventory/depends.txt
Normal file
1
mods/ctf_inventory/depends.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
ctf
|
|
@ -1,3 +1,7 @@
|
||||||
|
ctf.register_on_init(function()
|
||||||
|
ctf._set("inventory", false)
|
||||||
|
end)
|
||||||
|
|
||||||
local fs = "size[8,8.5]" ..
|
local fs = "size[8,8.5]" ..
|
||||||
"bgcolor[#080808BB;true]" ..
|
"bgcolor[#080808BB;true]" ..
|
||||||
"background[5,5;1,1;gui_formbg.png;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]"
|
"image[7,4.25;1,1;gui_hb_bg.png]"
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
player:set_inventory_formspec(fs)
|
if ctf.setting("inventory") then
|
||||||
|
player:set_inventory_formspec(fs)
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
ctf_stats = {}
|
ctf_stats = {}
|
||||||
|
|
||||||
function ctf_stats.load()
|
function ctf_stats.load()
|
||||||
print("load")
|
|
||||||
local file = io.open(minetest.get_worldpath().."/ctf_stats.txt", "r")
|
local file = io.open(minetest.get_worldpath().."/ctf_stats.txt", "r")
|
||||||
if file then
|
if file then
|
||||||
local table = minetest.deserialize(file:read("*all"))
|
local table = minetest.deserialize(file:read("*all"))
|
||||||
|
@ -44,7 +43,6 @@ ctf.register_on_save(function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
function ctf_stats.player(name)
|
function ctf_stats.player(name)
|
||||||
print("get " .. name)
|
|
||||||
local tplayer = ctf.player(name)
|
local tplayer = ctf.player(name)
|
||||||
local player = ctf_stats.players[name]
|
local player = ctf_stats.players[name]
|
||||||
if not player then
|
if not player then
|
||||||
|
@ -65,8 +63,6 @@ function ctf_stats.player(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
ctf.register_on_join_team(function(name, tname)
|
ctf.register_on_join_team(function(name, tname)
|
||||||
print("join team")
|
|
||||||
|
|
||||||
ctf_stats.current[tname][name] = {
|
ctf_stats.current[tname][name] = {
|
||||||
kills = 0,
|
kills = 0,
|
||||||
deaths = 0,
|
deaths = 0,
|
||||||
|
@ -75,56 +71,45 @@ ctf.register_on_join_team(function(name, tname)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
ctf_match.register_on_skip_map(function()
|
ctf_match.register_on_skip_map(function()
|
||||||
print("skip map")
|
|
||||||
|
|
||||||
ctf_stats.matches.skipped = ctf_stats.matches.skipped + 1
|
ctf_stats.matches.skipped = ctf_stats.matches.skipped + 1
|
||||||
end)
|
end)
|
||||||
|
|
||||||
ctf_match.register_on_winner(function(winner)
|
ctf_match.register_on_winner(function(winner)
|
||||||
print("win " .. winner)
|
|
||||||
|
|
||||||
ctf_stats.matches[winner .. "_wins"] = ctf_stats.matches[winner .. "_wins"] + 1
|
ctf_stats.matches[winner .. "_wins"] = ctf_stats.matches[winner .. "_wins"] + 1
|
||||||
end)
|
end)
|
||||||
|
|
||||||
ctf_match.register_on_new_match(function()
|
ctf_match.register_on_new_match(function()
|
||||||
print("new match")
|
|
||||||
|
|
||||||
-- TODO: create and show match report
|
-- TODO: create and show match report
|
||||||
|
|
||||||
print(dump(ctf_stats.matches))
|
|
||||||
print(dump(ctf_stats.current))
|
|
||||||
print(dump(ctf_stats.players))
|
|
||||||
|
|
||||||
ctf_stats.current = {
|
ctf_stats.current = {
|
||||||
red = {},
|
red = {},
|
||||||
blue = {}
|
blue = {}
|
||||||
}
|
}
|
||||||
minetest.after(3, function()
|
|
||||||
print(dump(ctf_stats.current))
|
|
||||||
end)
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
ctf_flag.register_on_pick_up(function(name, flag)
|
ctf_flag.register_on_pick_up(function(name, flag)
|
||||||
print("pick up")
|
|
||||||
local main, match = ctf_stats.player(name)
|
local main, match = ctf_stats.player(name)
|
||||||
main.attempts = main.attempts + 1
|
if main and match then
|
||||||
match.attempts = match.attempts + 1
|
main.attempts = main.attempts + 1
|
||||||
|
match.attempts = match.attempts + 1
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
ctf_flag.register_on_precapture(function(name, flag)
|
ctf_flag.register_on_precapture(function(name, flag)
|
||||||
print("capture")
|
|
||||||
local tplayer = ctf.player(name)
|
local tplayer = ctf.player(name)
|
||||||
local main, match = ctf_stats.player(name)
|
local main, match = ctf_stats.player(name)
|
||||||
main[tplayer.team .. "_wins"] = main[tplayer.team .. "_wins"] + 1
|
if main then
|
||||||
|
main[tplayer.team .. "_wins"] = main[tplayer.team .. "_wins"] + 1
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_dieplayer(function(player)
|
minetest.register_on_dieplayer(function(player)
|
||||||
print("die")
|
|
||||||
local main, match = ctf_stats.player(player:get_player_name())
|
local main, match = ctf_stats.player(player:get_player_name())
|
||||||
main.deaths = main.deaths + 1
|
if main and match then
|
||||||
match.deaths = match.deaths + 1
|
main.deaths = main.deaths + 1
|
||||||
|
match.deaths = match.deaths + 1
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
ctf_stats.load()
|
ctf_stats.load()
|
||||||
|
|
Loading…
Reference in a new issue