From 716657149780ee2ff4956d24ec69a0fa5599d14b Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Wed, 12 Aug 2015 12:32:40 +0100 Subject: [PATCH] Better formatting in README.md --- README.md | 64 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 1a3484c..bb77200 100644 --- a/README.md +++ b/README.md @@ -12,41 +12,43 @@ Licensed under WTFPL or CC0 (you choose) # Example ```lua +local function start_kick_vote(name, param) + if not minetest.get_player_by_name(param) then + minetest.chat_send_player(name, "There is no player called '" .. + param .. "'") + end + + vote.new_vote(name, { + description = "Kick player " .. param, + help = "/yes, /no or /abstain", + name = param, + duration = 60, + + 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, value) + minetest.chat_send_all(name .. " voted " .. value .. " to '" .. + self.description .. "'") + end + }) +end + minetest.register_chatcommand("vote_kick", { privs = { interact = true }, - func = function(name, param) - if not minetest.get_player_by_name(param) then - minetest.chat_send_player(name, "There is no player called '" .. - param .. "'") - end - - vote.new_vote(name, { - description = "Kick player " .. param, - help = "/yes, /no or /abstain", - name = param, - duration = 60, - - 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, value) - minetest.chat_send_all(name .. " voted " .. value .. " to '" .. - self.description .. "'") - end - }) - end + func = start_kick_vote }) ```