mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-27 05:13:48 +01:00
Bossbars: Add support for non-mob bosses
parent
2313012f60
commit
af044e6a96
@ -76,16 +76,23 @@ function mcl_bossbars.update_bar(id, def, priority)
|
|||||||
old.priority = priority or old.priority
|
old.priority = priority or old.priority
|
||||||
end
|
end
|
||||||
|
|
||||||
function mcl_bossbars.update_boss(luaentity, name, color)
|
function mcl_bossbars.update_boss(object, name, color)
|
||||||
local object = luaentity.object
|
local props = object:get_luaentity()
|
||||||
|
if not props or not props._cmi_is_mob then
|
||||||
|
props = object:get_properties()
|
||||||
|
props.health = object:get_hp()
|
||||||
|
end
|
||||||
|
|
||||||
local bardef = {
|
local bardef = {
|
||||||
text = luaentity.nametag,
|
|
||||||
percentage = math.floor(luaentity.health / luaentity.hp_max * 100),
|
|
||||||
color = color,
|
color = color,
|
||||||
|
text = props.nametag,
|
||||||
|
percentage = math.floor(props.health / props.hp_max * 100),
|
||||||
}
|
}
|
||||||
|
|
||||||
if not bardef.text or bardef.text == "" then
|
if not bardef.text or bardef.text == "" then
|
||||||
bardef.text = name
|
bardef.text = name
|
||||||
end
|
end
|
||||||
|
|
||||||
local pos = object:get_pos()
|
local pos = object:get_pos()
|
||||||
for _, player in pairs(minetest.get_connected_players()) do
|
for _, player in pairs(minetest.get_connected_players()) do
|
||||||
local d = vector.distance(pos, player:get_pos())
|
local d = vector.distance(pos, player:get_pos())
|
||||||
|
Loading…
Reference in New Issue
Block a user