An API to allow players to vote on things.
Dependencies: None
License: CC0
Download: https://github.com/minetest-mods/vote/a ... master.zip
or browse the code on GitHub
For kick voting, see https://github.com/rubenwardy/vote_kick/
Example API:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
vote.new_vote(name, {
description = "Kick player " .. param,
help = "/yes, /no or /abstain",
name = param,
duration = 60,
perc_needed = 0.8, -- fraction needed to pass the vote.
on_result = function(self, result, results)
if result == "yes" then
minetest.chat_send_all("Vote passed, " ..
#results.yes .. " to " .. #results.no .. ", " ..
self.name .. " will be kicked.")
minetest.kick_player(self.name, "The vote to kick you passed")
else
minetest.chat_send_all("Vote failed, " ..
#results.yes .. " to " .. #results.no .. ", " ..
self.name .. " remains ingame.")
end
end,
on_vote = function(self, name, vote)
minetest.chat_send_all(name .. " voted " .. vote .. " to '" ..
self.description .. "'")
end
})
Todo
- Show time remaining in HUD.
- Show queued votes on HUD.