Rename /vote_next to /vote
This commit is contained in:
parent
6bde327624
commit
a66745923c
1 changed files with 38 additions and 29 deletions
|
@ -6,36 +6,45 @@ function ctf_match.register_on_skip_map(func)
|
|||
table.insert(ctf_match.registered_on_skip_map, func)
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("vote_next", {
|
||||
function ctf_match.vote_next(name, params)
|
||||
vote.new_vote(name, {
|
||||
description = "Skip to next match",
|
||||
help = "/yes, /no or /abstain",
|
||||
duration = 60,
|
||||
perc_needed = 0.5,
|
||||
unanimous = 5,
|
||||
|
||||
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 match failed, " ..
|
||||
#results.no .. " to " .. #results.yes)
|
||||
end
|
||||
end,
|
||||
|
||||
on_vote = function(self, name, value)
|
||||
minetest.chat_send_all(name .. " voted " .. value .. " to '" ..
|
||||
self.description .. "'")
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("vote", {
|
||||
privs = {
|
||||
interact = true
|
||||
},
|
||||
func = function(name, param)
|
||||
vote.new_vote(name, {
|
||||
description = "Skip to next match",
|
||||
help = "/yes, /no or /abstain",
|
||||
duration = 60,
|
||||
perc_needed = 0.5,
|
||||
unanimous = 5,
|
||||
|
||||
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 match failed, " ..
|
||||
#results.no .. " to " .. #results.yes)
|
||||
end
|
||||
end,
|
||||
|
||||
on_vote = function(self, name, value)
|
||||
minetest.chat_send_all(name .. " voted " .. value .. " to '" ..
|
||||
self.description .. "'")
|
||||
end
|
||||
})
|
||||
end
|
||||
func = ctf_match.vote_next
|
||||
})
|
||||
|
||||
minetest.register_on_chat_message(function(name, msg)
|
||||
if msg == "/vote_next" then
|
||||
ctf_match.vote_next(name)
|
||||
return true
|
||||
end
|
||||
end)
|
||||
|
|
Loading…
Reference in a new issue