Fix vote related bugs
* Reset playertag on new match * Clear votes on new match
This commit is contained in:
parent
c1fe05b78f
commit
72c5afab55
5 changed files with 28 additions and 7 deletions
|
@ -40,6 +40,8 @@ function ctf_match.vote_next(name, params)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
ctf_match.register_on_new_match(vote.clear_vote)
|
||||||
|
|
||||||
minetest.register_chatcommand("vote", {
|
minetest.register_chatcommand("vote", {
|
||||||
privs = {
|
privs = {
|
||||||
interact = true,
|
interact = true,
|
||||||
|
|
|
@ -70,6 +70,14 @@ function playertag.set(player, type, color)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function playertag.get(player)
|
||||||
|
return tag_settings[player:get_player_by_name()]
|
||||||
|
end
|
||||||
|
|
||||||
|
function playertag.get_all()
|
||||||
|
return tag_settings
|
||||||
|
end
|
||||||
|
|
||||||
local nametag = {
|
local nametag = {
|
||||||
npcf_id = "nametag",
|
npcf_id = "nametag",
|
||||||
physical = false,
|
physical = false,
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
ctf_flag
|
ctf_flag
|
||||||
|
ctf_match
|
||||||
|
|
|
@ -2,7 +2,7 @@ dofile(minetest.get_modpath("playertag") .. "/api.lua")
|
||||||
|
|
||||||
ctf_flag.register_on_pick_up(function(attname, flag)
|
ctf_flag.register_on_pick_up(function(attname, flag)
|
||||||
playertag.set(minetest.get_player_by_name(attname), playertag.TYPE_BUILTIN,
|
playertag.set(minetest.get_player_by_name(attname), playertag.TYPE_BUILTIN,
|
||||||
{ a=255, r=255, g=0, b=0 })
|
{ a=255, r=255, g=0, b=0 })
|
||||||
end)
|
end)
|
||||||
|
|
||||||
ctf_flag.register_on_drop(function(attname, flag)
|
ctf_flag.register_on_drop(function(attname, flag)
|
||||||
|
@ -12,3 +12,11 @@ end)
|
||||||
ctf_flag.register_on_capture(function(attname, flag)
|
ctf_flag.register_on_capture(function(attname, flag)
|
||||||
playertag.set(minetest.get_player_by_name(attname), playertag.TYPE_ENTITY)
|
playertag.set(minetest.get_player_by_name(attname), playertag.TYPE_ENTITY)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
ctf_match.register_on_new_match(function()
|
||||||
|
for name, settings in pairs(playertag.get_all()) do
|
||||||
|
if settings.type == playertag.TYPE_BUILTIN then
|
||||||
|
playertag.set(minetest.get_player_by_name(name), playertag.TYPE_ENTITY)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
|
@ -146,15 +146,17 @@ minetest.register_privilege("vote_admin", {
|
||||||
description = "Allows a player to manage running votes."
|
description = "Allows a player to manage running votes."
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function vote.clear()
|
||||||
|
vote.active = {}
|
||||||
|
vote.queue = {}
|
||||||
|
vote.update_all_hud()
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_chatcommand("vote_clear", {
|
minetest.register_chatcommand("vote_clear", {
|
||||||
privs = {
|
privs = {
|
||||||
vote_admin = true,
|
vote_admin = true,
|
||||||
},
|
},
|
||||||
func = function(name, params)
|
func = vote.clear
|
||||||
vote.active = {}
|
|
||||||
vote.queue = {}
|
|
||||||
vote.update_all_hud()
|
|
||||||
end
|
|
||||||
})
|
})
|
||||||
|
|
||||||
local hudkit = dofile(minetest.get_modpath("vote") .. "/hudkit.lua")
|
local hudkit = dofile(minetest.get_modpath("vote") .. "/hudkit.lua")
|
||||||
|
@ -229,7 +231,7 @@ minetest.register_privilege("vote", {
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_privilege("vote_starter", {
|
minetest.register_privilege("vote_starter", {
|
||||||
description = "Can vote on issues",
|
description = "Can start votes on issues",
|
||||||
basic_priv = true
|
basic_priv = true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue