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!")
|
||||
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]+)}",
|
||||
function(res, pointer)
|
||||
if res[pointer] then
|
||||
|
|
|
@ -1,17 +1,24 @@
|
|||
local S = minetest.get_translator("mcl_commands")
|
||||
|
||||
mcl_commands.bossbar = {}
|
||||
mcl_commands.bossbar.dynamic_bosbars = {}
|
||||
|
||||
--1.13 feature
|
||||
--TODO: toggle it with setting/mod
|
||||
mcl_commands.register_command("bossbar", {
|
||||
func = function(cmd)
|
||||
cmd:sub("add", {
|
||||
func = function(name)
|
||||
return
|
||||
cmd:sub("add :id: :string:word", {
|
||||
func = function(name, id, string)
|
||||
mcl_commands.bossbar.dynamic_bosbars[id] = {text=string, color="white", percentage=100}
|
||||
return true, "Super"
|
||||
end,
|
||||
})
|
||||
cmd:sub("set", {
|
||||
func = function(name, target)
|
||||
return
|
||||
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)
|
||||
return true
|
||||
end,
|
||||
})
|
||||
cmd:sub("remove", {
|
||||
|
|
Loading…
Reference in New Issue