Page 1 of 1

[Mod] Vote [0.1] [vote] - an API

Posted: Thu Jul 16, 2015 16:46
by rubenwardy
Image

An API to allow players to vote on things.

Dependencies: None
License: CC0
Download: https://github.com/rubenwardy/vote/archive/master.zip
or browse the code on GitHub

For kick voting, see https://github.com/rubenwardy/vote_kick/

Example API:

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.

Re: [Mod] Vote (with Kick voting) [0.1] [vote] - an API

Posted: Fri Aug 21, 2015 09:18
by cd2
Thats cool!
I already thaught about making something like that, but your api is great!

Re: [Mod] Vote (with Kick voting) [0.1] [vote] - an API

Posted: Fri Aug 21, 2015 09:22
by Minetestforfun
Great work !
Needs to be used somewhere now :p

Re: [Mod] Vote (with Kick voting) [0.1] [vote] - an API

Posted: Fri Aug 21, 2015 09:37
by rubenwardy
It's used on my Capture the Flag server.

Re: [Mod] Vote (with Kick voting) [0.1] [vote] - an API

Posted: Fri Aug 21, 2015 10:00
by Minetestforfun
And aren't you afraid about player kick abuse ?

Example (wich happens very often in my HG server) :
10 players on the servers
A very great player wich play on a computer beat easily the android/tablet/weak other players.
So, three or four of the beated players say in loop "xxx cheat !" (because xxx, the great player, wins the 5 last games...)

Re: [Mod] Vote (with Kick voting) [0.1] [vote] - an API

Posted: Fri Aug 21, 2015 13:07
by rubenwardy
It's used to vote in a next game.

Re: [Mod] Vote [0.1] [vote] - an API

Posted: Fri Jul 07, 2017 10:40
by christoferlevich
I would like to set up a vote where I can allow players to vote on skipping the night - majority wins... I want to use this in conjunction with the 'bewareofthedark' mod (causes damage to player when in the dark after first draining a sanity hud bar) and it would be an awesome feature on our school server as the kids seem to hate the dark (and will hate it more when they start taking damage by it). I've added 'bewareof the dark' because my school district is heavy on non-violence but the game needed a mechanic to inspire hardcore players.

After all this - all I really need to know are the following things (lol)

1) Are there any tutorials I can review to grasp the concept you've set up better?
2) Is it even possible to do this? Can the VOTE mod skip to the morning?
3) I can envision huge possibilities for this in education. Perhaps I'll figure this out on my own, but I assume if I CAN skip the night with it, I'll be able to reward (or take from) students if I were to use vote for an educational question? (example: 1+1=X, answer options could be 2, 4, 5 (or whatever three options might fit) - if majority votes '2' the whole body of users are given an item - OR - if they vote '5' - they lose something of value (I could take cash, items, etc.)

I hope I am making sense. Every week I spend working in Minetest, then go back and read my posts, I realize I am asking a lot of questions that I end up answering just by trying stuff. Makes me look a little whacked sometimes, but its a great way to learn in the event that I am trying to 're-invent' the wheel. Thank you for your work! You're awesome for MT!

Re: [Mod] Vote [0.1] [vote] - an API

Posted: Mon Jul 10, 2017 15:41
by Sokomine
christoferlevich wrote: I would like to set up a vote where I can allow players to vote on skipping the night - majority wins...
IhrFussels server has a very similar functionality. It's not exactly a voting system - players may request night skipping and object to such a request from other players.

Re: [Mod] Vote [0.1] [vote] - an API

Posted: Mon Jul 10, 2017 23:36
by rubenwardy
christoferlevich wrote:I would like to set up a vote where I can allow players to vote on skipping the night - majority wins... I want to use this in conjunction with the 'bewareofthedark' mod (causes damage to player when in the dark after first draining a sanity hud bar) and it would be an awesome feature on our school server as the kids seem to hate the dark (and will hate it more when they start taking damage by it). I've added 'bewareof the dark' because my school district is heavy on non-violence but the game needed a mechanic to inspire hardcore players.

After all this - all I really need to know are the following things (lol)

1) Are there any tutorials I can review to grasp the concept you've set up better?
2) Is it even possible to do this? Can the VOTE mod skip to the morning?
3) I can envision huge possibilities for this in education. Perhaps I'll figure this out on my own, but I assume if I CAN skip the night with it, I'll be able to reward (or take from) students if I were to use vote for an educational question? (example: 1+1=X, answer options could be 2, 4, 5 (or whatever three options might fit) - if majority votes '2' the whole body of users are given an item - OR - if they vote '5' - they lose something of value (I could take cash, items, etc.)

I hope I am making sense. Every week I spend working in Minetest, then go back and read my posts, I realize I am asking a lot of questions that I end up answering just by trying stuff. Makes me look a little whacked sometimes, but its a great way to learn in the event that I am trying to 're-invent' the wheel. Thank you for your work! You're awesome for MT!
yes, this is a generic API to make voting on things easy.

See here for an example to register a vote which passes if 80% agree: https://github.com/rubenwardy/vote_kick ... r/init.lua

You'd need to change the onSuccess action from kick to day skip, and change 0.8 to 0.5 to get a 50% pass rate, and also rename it (ie: you don't want it to be called "kick")

If you have any more questions, please ask - I gtg.

The API documentation is in the README, it's more of a reference than a tutorial however: https://github.com/minetest-mods/vote

Re: [Mod] Vote [0.1] [vote] - an API

Posted: Tue Jul 11, 2017 15:12
by christoferlevich
I can't thank you enough! Once I get a grasp on it, maybe I can throw a tutorial together from a layman POV :) I might not be a real Minetest modder yet, but I have other stuff I can bring to the table as I learn :)

Re: [Mod] Vote [0.1] [vote] - an API

Posted: Sat Sep 23, 2017 21:02
by ManElevation
this is very usefull!
theres allways a noob annoying everyone.
this could even stop griefers

but i wount recompend this for server that have a low number of players.
for example theres 3 players in server
2 of them are friends and they want to kick the other for fun. so other player wont be able to play :O

Re: [Mod] Vote [0.1] [vote] - an API

Posted: Sat Sep 23, 2017 21:39
by rubenwardy
ManElevation wrote:this is very usefull!
theres allways a noob annoying everyone.
this could even stop griefers

but i wount recompend this for server that have a low number of players.
for example theres 3 players in server
2 of them are friends and they want to kick the other for fun. so other player wont be able to play :O
Note that this mod doesn't add kick voting, you need the other mod for that. I should probably make a forum topic for it. You can also set a minimum number of votes, btw

Re: [Mod] Vote [0.1] [vote] - an API

Posted: Sun Sep 24, 2017 01:17
by ManElevation
rubenwardy wrote:
ManElevation wrote:this is very usefull!
theres allways a noob annoying everyone.
this could even stop griefers

but i wount recompend this for server that have a low number of players.
for example theres 3 players in server
2 of them are friends and they want to kick the other for fun. so other player wont be able to play :O
Note that this mod doesn't add kick voting, you need the other mod for that. I should probably make a forum topic for it. You can also set a minimum number of votes, btw
Ohh that makes more sense, sorry I din't read the code before :l

Re: [Mod] Vote [0.1] [vote] - an API

Posted: Tue Sep 26, 2017 02:14
by SonosFuer
This is awesome, it would be cool if it also supported other generic questions such as tp requests. I like the idea of questions like that in the hud vs chat personally.

Re: [Mod] Vote [0.1] [vote] - an API

Posted: Tue Sep 26, 2017 13:53
by ManElevation
SonosFuer wrote:This is awesome, it would be cool if it also supported other generic questions such as tp requests. I like the idea of questions like that in the hud vs chat personally.
yea ruben, you should make a tpr mod that has a feature similar to this

Re: [Mod] Vote [0.1] [vote] - an API

Posted: Wed Feb 14, 2018 22:45
by scottwolff
I think this one looks better in principal than the voting both mod out there.