Ad vote module and correct readme

This commit is contained in:
orwell96 2018-01-29 23:35:17 +01:00
parent 63c1c28386
commit 970b1834f8
4 changed files with 98 additions and 7 deletions

View File

@ -1 +1 @@
vote?

View File

@ -12,7 +12,7 @@ if not mpd.modpath then
end
--{name, length, gain~1}
mpd.songs = {}
local sfile, sfileerr=io.open(mpd.modpath.."/songs.txt")
local sfile, sfileerr=io.open(mpd.modpath..DIR_DELIM.."songs.txt")
if not sfile then error("Error opening songs.txt: "..sfileerr) end
for line in sfile:lines() do
if line~="" and line[1]~="#" then
@ -206,3 +206,7 @@ minetest.register_chatcommand("mvolume", {
end
end,
})
if vote then
dofile(mpd.modpath..DIR_DELIM.."vote.lua")
end

View File

@ -5,15 +5,34 @@ This mod is licensed under the WTFPL.
Adds an easy but powerful background music backend.
Music credits:
## Usage:
For all players:
/mvolume <volume>
Set your individual music volume or disable background music (/mvolume 0). Saved across server restarts.
/mpd_list: list available music
With mpd privilege:
/mpd_play <id>: play a song
/mpd_stop: stop the current song. Unless /mpd_play or /mpd_next are invoked, no more music is played
/mpd_next [time]: Play the next song after [time] seconds, immediately if omitted.
## Votes:
This mod integrates with the [vote] mod by rubenwardy (https://github.com/minetest-mods/vote)
/vote_mpd_next - vote to start next song
/vote_mpd_play <id> - Vote to play certain sing
## Music credits:
StrangelyBeautifulShort 3:01 0.7
AvalonShort 2:58 1.4
eastern_feeling 3:51 1.0
EtherealShort 3:04 0.7
FarawayShort 3:05 0.7
dark_ambiance 0:44 1.0
-> see the [ambience] mod for copyright info, I couldn't find any.
-> Music from [ambience] mod
-> Author is Amethystium <http://amethystium.com/>.
eastern_feeling 3:51 1.0
-> created by Jordach. It can be found in the BFD subgame. License is GPLv3 (license of BFD).
bensound_deepblue 4:48 1.0
bensound_ofeliasdream 4:59 1.0
@ -22,4 +41,4 @@ bensound_slowmotion 3:26 1.0
rainymemory 2:10 1.0
anonnp4014 2:30 1.6
-> (c) Deemo collection (game music collection)
-> (c) Deemo collection (game music collection)

68
vote.lua Normal file
View File

@ -0,0 +1,68 @@
--mpd
--vote.lua - vote module to change songs
function mpd.vote_play(name, param)
id=tonumber(param)
if id and id>0 and id<=#mpd.songs then
vote.new_vote(name, {
description = "Play "..mpd.song_human_readable(id),
help = "/yes or /no",
duration = 20,
perc_needed = 0.4,
on_result = function(self, result, results)
if result == "yes" then
minetest.chat_send_all("Vote to play " .. mpd.song_human_readable(id) .. " passed " ..
#results.yes .. " to " .. #results.no)
mpd.play_song(id)
else
minetest.chat_send_all("Vote to play " .. mpd.song_human_readable(id) .. " failed " ..
#results.yes .. " to " .. #results.no)
end
end,
on_vote = function(self, name, value)
minetest.chat_send_all(name .. " voted " .. value .. " to '" ..
self.description .. "'")
end,
})
return true
end
return false,"Invalid song ID! See available song IDs using /mpd_list"
end
minetest.register_chatcommand("vote_mpd_play", {
func = mpd.vote_play
})
function mpd.vote_next(name, param)
vote.new_vote(name, {
description = "Play next song",
help = "/yes or /no",
duration = 20,
perc_needed = 0.4,
on_result = function(self, result, results)
minetest.chat_send_all(result..dump(results))
if result == "yes" then
minetest.chat_send_all("Vote to play next song passed " ..
#results.yes .. " to " .. #results.no)
mpd.next_song()
else
minetest.chat_send_all("Vote to play next song failed " ..
#results.yes .. " to " .. #results.no)
end
end,
on_vote = function(self, name, value)
minetest.chat_send_all(name .. " voted " .. value .. " to '" ..
self.description .. "'")
end
})
return true
end
minetest.register_chatcommand("vote_mpd_next", {
func = mpd.vote_next
})