Исправить ошибку вылета и формирования списка, добавить команду очистки:

- добавлена переменная хранилища, вызываемая при загрузке мода;
- добавлен разделитель в команде добавления  в список игнорируемых;
- добавлена команда очистки списка.
This commit is contained in:
Aleksandr Avdeev 2024-12-09 10:51:40 +03:00
parent 64fa36a0d8
commit f3b318f16e

View File

@ -3,6 +3,8 @@ vote = {
queue = {}
}
local storage = core.get_mod_storage()
function vote.new_vote(creator, voteset)
local max_votes = tonumber(minetest.setting_get("vote.maximum_active")) or 1
@ -110,7 +112,7 @@ end
function vote.check_vote(voteset)
local all_players_voted = true
local players = minetest.get_connected_players()
local ignored_players = core.get_mod_storage():get_string("ignored_players"):split(" ")
local ignored_players = storage:get_string("ignored_players"):split(" ")
for _, player in pairs(players) do
local name = player:get_player_name()
local is_ignored = false
@ -309,7 +311,7 @@ minetest.register_chatcommand("vote_ignored", {
func = function(name, params)
minetest.chat_send_player(
name,
"Ignored players: " .. core.get_mod_storage():get_string("ignored_players")
"Ignored players: " .. storage:get_string("ignored_players")
)
end
})
@ -321,10 +323,23 @@ minetest.register_chatcommand("vote_ignore", {
description = "Ignore player(s) during voting",
params = "<PlayerName>...",
func = function(name, params)
local meta = core.get_mod_storage()
meta:set_string(
storage:set_string(
"ignored_players",
meta:get_string("ignored_players") .. params
storage:get_string("ignored_players") .. params.. " "
)
end
})
minetest.register_chatcommand("vote_ignored_clear", {
privs = {
vote_admin = true,
},
description = "Clear list of players ignored during voting",
func = function(name, params)
storage:set_string("ignored_players","")
minetest.chat_send_player(
name,
"The list of ignored players has been cleared"
)
end
})