mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-04-01 01:40:29 +02:00
use alternative to colorspec_to_bytes
This commit is contained in:
parent
70118fc8da
commit
d4a25064ea
22
api.lua
22
api.lua
@ -14,7 +14,7 @@ local use_vh1 = minetest.get_modpath("visual_harm_1ndicators")
|
|||||||
-- Global
|
-- Global
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20240130",
|
version = "20240201",
|
||||||
translate = S,
|
translate = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {},
|
invis = minetest.global_exists("invisibility") and invisibility or {},
|
||||||
node_snow = minetest.registered_aliases["mapgen_snow"]
|
node_snow = minetest.registered_aliases["mapgen_snow"]
|
||||||
@ -656,7 +656,7 @@ function mob_class:update_tag(newname)
|
|||||||
local qua = prop.hp_max / 6
|
local qua = prop.hp_max / 6
|
||||||
|
|
||||||
local old_nametag = prop.nametag
|
local old_nametag = prop.nametag
|
||||||
local old_nametag_color = minetest.colorspec_to_bytes(prop.nametag_color)
|
local old_nametag_color = self.nametag_col
|
||||||
|
|
||||||
-- backwards compatibility
|
-- backwards compatibility
|
||||||
if self.nametag and self.nametag ~= "" then
|
if self.nametag and self.nametag ~= "" then
|
||||||
@ -670,22 +670,22 @@ function mob_class:update_tag(newname)
|
|||||||
|
|
||||||
-- choose tag colour depending on mob health
|
-- choose tag colour depending on mob health
|
||||||
if self.health <= qua then
|
if self.health <= qua then
|
||||||
col = "#FF0000"
|
self.nametag_col = "#FF0000"
|
||||||
elseif self.health <= (qua * 2) then
|
elseif self.health <= (qua * 2) then
|
||||||
col = "#FF7A00"
|
self.nametag_col = "#FF7A00"
|
||||||
elseif self.health <= (qua * 3) then
|
elseif self.health <= (qua * 3) then
|
||||||
col = "#FFB500"
|
self.nametag_col = "#FFB500"
|
||||||
elseif self.health <= (qua * 4) then
|
elseif self.health <= (qua * 4) then
|
||||||
col = "#FFFF00"
|
self.nametag_col = "#FFFF00"
|
||||||
elseif self.health <= (qua * 5) then
|
elseif self.health <= (qua * 5) then
|
||||||
col = "#B4FF00"
|
self.nametag_col = "#B4FF00"
|
||||||
elseif self.health > (qua * 5) then
|
elseif self.health > (qua * 5) then
|
||||||
col = "#00FF00"
|
self.nametag_col = "#00FF00"
|
||||||
end
|
end
|
||||||
|
|
||||||
if self._nametag ~= old_nametag
|
if self._nametag ~= old_nametag or self.nametag_col ~= old_nametag_color then
|
||||||
or minetest.colorspec_to_bytes(col) ~= old_nametag_color then
|
self.object:set_properties({
|
||||||
self.object:set_properties({nametag = self._nametag, nametag_color = col})
|
nametag = self._nametag, nametag_color = self.nametag_col})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user