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

Post Reply
User avatar
rubenwardy
Moderator
Posts: 6969
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

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

by rubenwardy » Post

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.
Last edited by rubenwardy on Fri Mar 17, 2017 23:55, edited 6 times in total.
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
cd2
Member
Posts: 562
Joined: Mon Jun 01, 2015 06:30
GitHub: cdqwertz
In-game: cd cd2
Location: Linux
Contact:

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

by cd2 » Post

Thats cool!
I already thaught about making something like that, but your api is great!

User avatar
Minetestforfun
Member
Posts: 940
Joined: Tue Aug 05, 2014 14:09
GitHub: MinetestForFun
IRC: MinetestForFun
In-game: MinetestForFun
Location: On earth
Contact:

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

by Minetestforfun » Post

Great work !
Needs to be used somewhere now :p

User avatar
rubenwardy
Moderator
Posts: 6969
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

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

by rubenwardy » Post

It's used on my Capture the Flag server.
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
Minetestforfun
Member
Posts: 940
Joined: Tue Aug 05, 2014 14:09
GitHub: MinetestForFun
IRC: MinetestForFun
In-game: MinetestForFun
Location: On earth
Contact:

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

by Minetestforfun » Post

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...)

User avatar
rubenwardy
Moderator
Posts: 6969
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

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

by rubenwardy » Post

It's used to vote in a next game.
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
christoferlevich
Member
Posts: 325
Joined: Thu Dec 01, 2016 23:44
GitHub: ChristoferL
Location: Athol, Massachusetts

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

by christoferlevich » Post

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!
everything can be a learning experience...

Sokomine
Member
Posts: 4276
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

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

by Sokomine » Post

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.
A list of my mods can be found here.

User avatar
rubenwardy
Moderator
Posts: 6969
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

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

by rubenwardy » Post

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
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
christoferlevich
Member
Posts: 325
Joined: Thu Dec 01, 2016 23:44
GitHub: ChristoferL
Location: Athol, Massachusetts

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

by christoferlevich » Post

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 :)
everything can be a learning experience...

User avatar
ManElevation
Member
Posts: 896
Joined: Tue Aug 02, 2016 22:04
GitHub: ManElevation
IRC: ManElevation
In-game: ManElevation
Location: Madrid,Spain

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

by ManElevation » Post

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
My Public Mods! Discord: Rottweiler Games#3368

User avatar
rubenwardy
Moderator
Posts: 6969
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

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

by rubenwardy » Post

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
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
ManElevation
Member
Posts: 896
Joined: Tue Aug 02, 2016 22:04
GitHub: ManElevation
IRC: ManElevation
In-game: ManElevation
Location: Madrid,Spain

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

by ManElevation » Post

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
My Public Mods! Discord: Rottweiler Games#3368

User avatar
SonosFuer
Member
Posts: 104
Joined: Sun Jul 09, 2017 00:32
GitHub: apachano
IRC: SonosFuer
In-game: SonosFuer

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

by SonosFuer » Post

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.
Working on a content database for minetest mods, servers, and etc Check it out and give me feedback at viewtopic.php?f=14&t=18137

User avatar
ManElevation
Member
Posts: 896
Joined: Tue Aug 02, 2016 22:04
GitHub: ManElevation
IRC: ManElevation
In-game: ManElevation
Location: Madrid,Spain

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

by ManElevation » Post

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
My Public Mods! Discord: Rottweiler Games#3368

User avatar
scottwolff
Member
Posts: 129
Joined: Sat Apr 30, 2016 06:15
In-game: scottwolff or some variant of iasiney
Location: Central Illinois

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

by scottwolff » Post

I think this one looks better in principal than the voting both mod out there.

Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests