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

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

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

by rubenwardy » Thu Jul 16, 2015 16:46

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.
Core Developer | Donate | My Twitter | Mods | Mods 4 Android | Node Box Editor | Minetest Modding Book

Hello profile reader

LgiOxMFYXOqtqVqMPhbw1Bn3oNRvEC7j
 

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

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

by cd2 » Fri Aug 21, 2015 09:18

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

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

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

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

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

by Minetestforfun » Fri Aug 21, 2015 10:00

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: 5317
Joined: Tue Jun 12, 2012 18:11
Location: United Kingdom
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
 

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

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

by christoferlevich » Fri Jul 07, 2017 10:40

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: 3482
Joined: Sun Sep 09, 2012 17:31

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

by Sokomine » Mon Jul 10, 2017 15:41

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: 5317
Joined: Tue Jun 12, 2012 18:11
Location: United Kingdom
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

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

by rubenwardy » Mon Jul 10, 2017 23:36

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
Core Developer | Donate | My Twitter | Mods | Mods 4 Android | Node Box Editor | Minetest Modding Book

Hello profile reader

LgiOxMFYXOqtqVqMPhbw1Bn3oNRvEC7j
 

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

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

by christoferlevich » Tue Jul 11, 2017 15:12

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: 767
Joined: Tue Aug 02, 2016 22:04
Location: Madrid,Spain
GitHub: ManElevation
IRC: ManElevation
In-game: ManElevation

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

by ManElevation » Sat Sep 23, 2017 21:02

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
 

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

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

by rubenwardy » Sat Sep 23, 2017 21:39

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
Core Developer | Donate | My Twitter | Mods | Mods 4 Android | Node Box Editor | Minetest Modding Book

Hello profile reader

LgiOxMFYXOqtqVqMPhbw1Bn3oNRvEC7j
 

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

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

by ManElevation » Sun Sep 24, 2017 01:17

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
 

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 » Tue Sep 26, 2017 02:14

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 https://forum.minetest.net/viewtopic.php?f=14&t=18137
 

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

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

by ManElevation » Tue Sep 26, 2017 13:53

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
 

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

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

by scottwolff » Wed Feb 14, 2018 22:45

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


Return to Mod Releases



Who is online

Users browsing this forum: R-One and 6 guests