mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-03-26 14:00:32 +01:00
only update object props when changes (thx whosit)
This commit is contained in:
parent
7c7a7345af
commit
70118fc8da
14
api.lua
14
api.lua
@ -14,7 +14,7 @@ local use_vh1 = minetest.get_modpath("visual_harm_1ndicators")
|
|||||||
-- Global
|
-- Global
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20240126",
|
version = "20240130",
|
||||||
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"]
|
||||||
@ -655,6 +655,9 @@ function mob_class:update_tag(newname)
|
|||||||
local prop = self.object:get_properties()
|
local prop = self.object:get_properties()
|
||||||
local qua = prop.hp_max / 6
|
local qua = prop.hp_max / 6
|
||||||
|
|
||||||
|
local old_nametag = prop.nametag
|
||||||
|
local old_nametag_color = minetest.colorspec_to_bytes(prop.nametag_color)
|
||||||
|
|
||||||
-- backwards compatibility
|
-- backwards compatibility
|
||||||
if self.nametag and self.nametag ~= "" then
|
if self.nametag and self.nametag ~= "" then
|
||||||
newname = self.nametag
|
newname = self.nametag
|
||||||
@ -680,7 +683,10 @@ function mob_class:update_tag(newname)
|
|||||||
col = "#00FF00"
|
col = "#00FF00"
|
||||||
end
|
end
|
||||||
|
|
||||||
self.object:set_properties({nametag = self._nametag, nametag_color = col})
|
if self._nametag ~= old_nametag
|
||||||
|
or minetest.colorspec_to_bytes(col) ~= old_nametag_color then
|
||||||
|
self.object:set_properties({nametag = self._nametag, nametag_color = col})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local text = ""
|
local text = ""
|
||||||
@ -709,7 +715,9 @@ function mob_class:update_tag(newname)
|
|||||||
.. text
|
.. text
|
||||||
|
|
||||||
-- set infotext changes
|
-- set infotext changes
|
||||||
self.object:set_properties({infotext = self.infotext})
|
if self.infotext ~= prop.infotext then
|
||||||
|
self.object:set_properties({infotext = self.infotext})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user