diff --git a/mods/ctf_inventory/depends.txt b/mods/ctf_inventory/depends.txt new file mode 100644 index 0000000..0dcc91d --- /dev/null +++ b/mods/ctf_inventory/depends.txt @@ -0,0 +1 @@ +ctf diff --git a/mods/ctf_inventory/init.lua b/mods/ctf_inventory/init.lua index 0191857..4baa0df 100644 --- a/mods/ctf_inventory/init.lua +++ b/mods/ctf_inventory/init.lua @@ -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) - player:set_inventory_formspec(fs) + if ctf.setting("inventory") then + player:set_inventory_formspec(fs) + end end) diff --git a/mods/ctf_stats/init.lua b/mods/ctf_stats/init.lua index c1ee857..898ad35 100644 --- a/mods/ctf_stats/init.lua +++ b/mods/ctf_stats/init.lua @@ -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) - main.attempts = main.attempts + 1 - match.attempts = match.attempts + 1 + 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) - main[tplayer.team .. "_wins"] = main[tplayer.team .. "_wins"] + 1 - + 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()) - main.deaths = main.deaths + 1 - match.deaths = match.deaths + 1 + if main and match then + main.deaths = main.deaths + 1 + match.deaths = match.deaths + 1 + end end) ctf_stats.load()