From 72c5afab559e22db50b9cfb464566b1a5fffb6bd Mon Sep 17 00:00:00 2001 From: ClobberXD Date: Mon, 20 Aug 2018 15:53:42 +0530 Subject: [PATCH] Fix vote related bugs * Reset playertag on new match * Clear votes on new match --- mods/ctf_match/vote.lua | 2 ++ mods/playertag/api.lua | 8 ++++++++ mods/playertag/depends.txt | 1 + mods/playertag/init.lua | 10 +++++++++- mods/vote/init.lua | 14 ++++++++------ 5 files changed, 28 insertions(+), 7 deletions(-) diff --git a/mods/ctf_match/vote.lua b/mods/ctf_match/vote.lua index c8a10b5..c61c484 100644 --- a/mods/ctf_match/vote.lua +++ b/mods/ctf_match/vote.lua @@ -40,6 +40,8 @@ function ctf_match.vote_next(name, params) }) end +ctf_match.register_on_new_match(vote.clear_vote) + minetest.register_chatcommand("vote", { privs = { interact = true, diff --git a/mods/playertag/api.lua b/mods/playertag/api.lua index 4804871..7fc6c78 100644 --- a/mods/playertag/api.lua +++ b/mods/playertag/api.lua @@ -70,6 +70,14 @@ function playertag.set(player, type, color) 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 = { npcf_id = "nametag", physical = false, diff --git a/mods/playertag/depends.txt b/mods/playertag/depends.txt index 5e62704..554e119 100644 --- a/mods/playertag/depends.txt +++ b/mods/playertag/depends.txt @@ -1 +1,2 @@ ctf_flag +ctf_match diff --git a/mods/playertag/init.lua b/mods/playertag/init.lua index 342ed8a..89cc52e 100644 --- a/mods/playertag/init.lua +++ b/mods/playertag/init.lua @@ -2,7 +2,7 @@ dofile(minetest.get_modpath("playertag") .. "/api.lua") ctf_flag.register_on_pick_up(function(attname, flag) 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) ctf_flag.register_on_drop(function(attname, flag) @@ -12,3 +12,11 @@ end) ctf_flag.register_on_capture(function(attname, flag) playertag.set(minetest.get_player_by_name(attname), playertag.TYPE_ENTITY) 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) diff --git a/mods/vote/init.lua b/mods/vote/init.lua index fd51883..3837f4e 100644 --- a/mods/vote/init.lua +++ b/mods/vote/init.lua @@ -146,15 +146,17 @@ minetest.register_privilege("vote_admin", { 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", { privs = { vote_admin = true, }, - func = function(name, params) - vote.active = {} - vote.queue = {} - vote.update_all_hud() - end + func = vote.clear }) local hudkit = dofile(minetest.get_modpath("vote") .. "/hudkit.lua") @@ -229,7 +231,7 @@ minetest.register_privilege("vote", { }) minetest.register_privilege("vote_starter", { - description = "Can vote on issues", + description = "Can start votes on issues", basic_priv = true })