Add ctf_stats, remove furnace

This commit is contained in:
rubenwardy 2015-11-29 00:05:37 +00:00
parent b366e51f5a
commit 79238968d6
8 changed files with 160 additions and 305 deletions

View file

@ -14,6 +14,14 @@ function ctf_match.register_on_new_match(func)
table.insert(ctf_match.registered_on_new_match, func)
end
ctf_match.registered_on_winner = {}
function ctf_match.register_on_winner(func)
if ctf._mt_loaded then
error("You can't register callbacks at game time!")
end
table.insert(ctf_match.registered_on_winner, func)
end
-- Load next match. May be overrided
function ctf_match.next()
@ -38,6 +46,9 @@ function ctf_match.check_for_winner()
-- There is a winner!
ctf.action("match", winner .. " won!")
minetest.chat_send_all("Team " .. winner .. " won!")
for i = 1, #ctf_match.registered_on_winner do
ctf_match.registered_on_winner[i](winner)
end
if ctf.setting("match") then
ctf_match.next()
end

View file

@ -1,10 +1,18 @@
ctf_match.registered_on_skip_map = {}
function ctf_match.register_on_skip_map(func)
if ctf._mt_loaded then
error("You can't register callbacks at game time!")
end
table.insert(ctf_match.registered_on_skip_map, func)
end
minetest.register_chatcommand("vote_next", {
privs = {
interact = true
},
func = function(name, param)
vote.new_vote(name, {
description = "Skip to next map",
description = "Skip to next match",
help = "/yes, /no or /abstain",
duration = 60,
perc_needed = 0.5,
@ -12,10 +20,15 @@ minetest.register_chatcommand("vote_next", {
on_result = function(self, result, results)
if result == "yes" then
minetest.chat_send_all("Vote to skip match passed, " ..
#results.yes .. " to " .. #results.no)
for i = 1, #ctf_match.registered_on_skip_map do
ctf_match.registered_on_skip_map[i]()
end
ctf_match.next()
else
minetest.chat_send_all("Vote to skip map failed, " ..
#results.yes .. " to " .. #results.no)
minetest.chat_send_all("Vote to skip match failed, " ..
#results.no .. " to " .. #results.yes)
end
end,