forked from VoxeLibre/VoxeLibre
improve bossbar command (WIP)
This commit is contained in:
parent
698b107cb3
commit
e0fcfc1888
|
@ -52,6 +52,14 @@ mcl_commands.types = {
|
||||||
return S("Word is invalid!")
|
return S("Word is invalid!")
|
||||||
end
|
end
|
||||||
end},
|
end},
|
||||||
|
quotestring = {[["([^ ]+)"]],
|
||||||
|
function(res, pointer)
|
||||||
|
if res[pointer] == tostring(res[pointer]) then
|
||||||
|
return nil, string.sub(tostring(res[pointer]), 2, #res[pointer]-1), pointer+1
|
||||||
|
else
|
||||||
|
return S("String is invalid!")
|
||||||
|
end
|
||||||
|
end},
|
||||||
alpha = {"([A-Za-z]+)}",
|
alpha = {"([A-Za-z]+)}",
|
||||||
function(res, pointer)
|
function(res, pointer)
|
||||||
if res[pointer] then
|
if res[pointer] then
|
||||||
|
|
|
@ -1,17 +1,24 @@
|
||||||
local S = minetest.get_translator("mcl_commands")
|
local S = minetest.get_translator("mcl_commands")
|
||||||
|
|
||||||
|
mcl_commands.bossbar = {}
|
||||||
|
mcl_commands.bossbar.dynamic_bosbars = {}
|
||||||
|
|
||||||
--1.13 feature
|
--1.13 feature
|
||||||
--TODO: toggle it with setting/mod
|
--TODO: toggle it with setting/mod
|
||||||
mcl_commands.register_command("bossbar", {
|
mcl_commands.register_command("bossbar", {
|
||||||
func = function(cmd)
|
func = function(cmd)
|
||||||
cmd:sub("add", {
|
cmd:sub("add :id: :string:word", {
|
||||||
func = function(name)
|
func = function(name, id, string)
|
||||||
return
|
mcl_commands.bossbar.dynamic_bosbars[id] = {text=string, color="white", percentage=100}
|
||||||
|
return true, "Super"
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
cmd:sub("set", {
|
cmd:sub("set :id: players :value:word", {
|
||||||
func = function(name, target)
|
func = function(name, id, value)
|
||||||
return
|
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)
|
||||||
|
return true
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
cmd:sub("remove", {
|
cmd:sub("remove", {
|
||||||
|
|
Loading…
Reference in New Issue