From 0c32c94f734e10a416d0eb81751c3bcdd6ddd6b8 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Wed, 7 Apr 2021 23:38:44 +0200 Subject: [PATCH] add basic command --- mods/MISC/mcl_basic_commands/bossbar.lua | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/mods/MISC/mcl_basic_commands/bossbar.lua b/mods/MISC/mcl_basic_commands/bossbar.lua index dadd018474..2902055fd5 100644 --- a/mods/MISC/mcl_basic_commands/bossbar.lua +++ b/mods/MISC/mcl_basic_commands/bossbar.lua @@ -1,7 +1,14 @@ local S = minetest.get_translator("mcl_commands") mcl_commands.bossbar = {} -mcl_commands.bossbar.dynamic_bosbars = {} +mcl_commands.bossbar.registered_dynamic = {} + +local players_ids = {} + +function mcl_commands.bossbar.update_by_id(id) + local def = mcl_commands.bossbar.registered_dynamic[id] + mcl_bossbars.add_bar(minetest.get_player_by_name(def.players), {text=def.text, color=def.color, percentage=def.percentage}) +end --1.13 feature --TODO: toggle it with setting/mod @@ -9,26 +16,26 @@ mcl_commands.register_command("bossbar", { func = function(cmd) cmd:sub("add :id: :string:word", { func = function(name, id, string) - mcl_commands.bossbar.dynamic_bosbars[id] = {text=string, color="white", percentage=100} + mcl_commands.bossbar.registered_dynamic[id] = {text=string, color="white", percentage=100, players=nil} --set percentage to 0 return true, "Super" end, }) cmd:sub("set :id: players :value:word", { func = function(name, id, value) - mcl_commands.bossbar.dynamic_bosbars[id].players = value - local def = mcl_commands.bossbar.dynamic_bosbars[id] - mcl_bossbars.update_bar(minetest.get_player_by_name(name), def.text, def.color, def.percentage) + mcl_commands.bossbar.registered_dynamic[id].players=value + mcl_commands.bossbar.update_by_id(id) return true end, }) cmd:sub("remove", { func = function(name, target) - return + mcl_commands.bossbar.registered_dynamic[id] = nil + return true end, }) cmd:sub("get", { func = function(name, target) - return + return true end, }) end,