capturetheflag/mods/ctf_match/vote.lua

42 lines
1.1 KiB
Lua
Raw Normal View History

2015-11-29 00:05:37 +00:00
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
2015-07-17 17:10:17 +00:00
minetest.register_chatcommand("vote_next", {
privs = {
interact = true
},
func = function(name, param)
vote.new_vote(name, {
2015-11-29 00:05:37 +00:00
description = "Skip to next match",
2015-07-17 17:10:17 +00:00
help = "/yes, /no or /abstain",
duration = 60,
perc_needed = 0.5,
unanimous = 5,
on_result = function(self, result, results)
if result == "yes" then
2015-11-29 00:05:37 +00:00
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
2015-07-17 17:10:17 +00:00
ctf_match.next()
else
2015-11-29 00:05:37 +00:00
minetest.chat_send_all("Vote to skip match failed, " ..
#results.no .. " to " .. #results.yes)
2015-07-17 17:10:17 +00:00
end
end,
on_vote = function(self, name, value)
minetest.chat_send_all(name .. " voted " .. value .. " to '" ..
self.description .. "'")
end
})
end
})