forked from VoxeLibre/VoxeLibre
add basic command
This commit is contained in:
parent
e463d16298
commit
0c32c94f73
|
@ -1,7 +1,14 @@
|
||||||
local S = minetest.get_translator("mcl_commands")
|
local S = minetest.get_translator("mcl_commands")
|
||||||
|
|
||||||
mcl_commands.bossbar = {}
|
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
|
--1.13 feature
|
||||||
--TODO: toggle it with setting/mod
|
--TODO: toggle it with setting/mod
|
||||||
|
@ -9,26 +16,26 @@ mcl_commands.register_command("bossbar", {
|
||||||
func = function(cmd)
|
func = function(cmd)
|
||||||
cmd:sub("add :id: :string:word", {
|
cmd:sub("add :id: :string:word", {
|
||||||
func = function(name, id, string)
|
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"
|
return true, "Super"
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
cmd:sub("set :id: players :value:word", {
|
cmd:sub("set :id: players :value:word", {
|
||||||
func = function(name, id, value)
|
func = function(name, id, value)
|
||||||
mcl_commands.bossbar.dynamic_bosbars[id].players = value
|
mcl_commands.bossbar.registered_dynamic[id].players=value
|
||||||
local def = mcl_commands.bossbar.dynamic_bosbars[id]
|
mcl_commands.bossbar.update_by_id(id)
|
||||||
mcl_bossbars.update_bar(minetest.get_player_by_name(name), def.text, def.color, def.percentage)
|
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
cmd:sub("remove", {
|
cmd:sub("remove", {
|
||||||
func = function(name, target)
|
func = function(name, target)
|
||||||
return
|
mcl_commands.bossbar.registered_dynamic[id] = nil
|
||||||
|
return true
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
cmd:sub("get", {
|
cmd:sub("get", {
|
||||||
func = function(name, target)
|
func = function(name, target)
|
||||||
return
|
return true
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
|
|
Loading…
Reference in New Issue