mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-01-10 09:50:19 +01:00
change self.nametag to self._nametag (get_properties causing issue)
This commit is contained in:
parent
c173345135
commit
6172203e0e
44
api.lua
44
api.lua
@ -730,12 +730,22 @@ local CHILD_GROW_TIME = 60 * 20 -- 20 minutes
|
|||||||
|
|
||||||
|
|
||||||
-- update nametag and infotext
|
-- update nametag and infotext
|
||||||
function mob_class:update_tag()
|
function mob_class:update_tag(newname)
|
||||||
|
|
||||||
local col
|
local col
|
||||||
local prop = self.object:get_properties()
|
local prop = self.object:get_properties()
|
||||||
local qua = prop.hp_max / 6
|
local qua = prop.hp_max / 6
|
||||||
|
|
||||||
|
-- backwards compatibility
|
||||||
|
if self.nametag and self.nametag ~= "" then
|
||||||
|
newname = self.nametag
|
||||||
|
self.nametag = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
if newname or (self._nametag and self._nametag ~= "") then
|
||||||
|
|
||||||
|
self._nametag = newname or self._nametag -- adopt new name if one found
|
||||||
|
|
||||||
if self.health <= qua then
|
if self.health <= qua then
|
||||||
col = "#FF0000"
|
col = "#FF0000"
|
||||||
elseif self.health <= (qua * 2) then
|
elseif self.health <= (qua * 2) then
|
||||||
@ -750,6 +760,9 @@ function mob_class:update_tag()
|
|||||||
col = "#00FF00"
|
col = "#00FF00"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self.object:set_properties({nametag = self._nametag, nametag_color = col})
|
||||||
|
end
|
||||||
|
|
||||||
local text = ""
|
local text = ""
|
||||||
|
|
||||||
if self.horny == true then
|
if self.horny == true then
|
||||||
@ -773,9 +786,8 @@ function mob_class:update_tag()
|
|||||||
.. (self.owner == "" and "" or "\nOwner: " .. self.owner)
|
.. (self.owner == "" and "" or "\nOwner: " .. self.owner)
|
||||||
.. text
|
.. text
|
||||||
|
|
||||||
-- set changes
|
-- set infotext changes
|
||||||
self.object:set_properties({
|
self.object:set_properties({infotext = self.infotext})
|
||||||
nametag = self.nametag, nametag_color = col, infotext = self.infotext})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -1078,10 +1090,10 @@ end
|
|||||||
-- environmental damage (water, lava, fire, light etc.)
|
-- environmental damage (water, lava, fire, light etc.)
|
||||||
function mob_class:do_env_damage()
|
function mob_class:do_env_damage()
|
||||||
|
|
||||||
self:update_tag()
|
|
||||||
|
|
||||||
local pos = self.object:get_pos() ; if not pos then return end
|
local pos = self.object:get_pos() ; if not pos then return end
|
||||||
|
|
||||||
|
self:update_tag()
|
||||||
|
|
||||||
self.time_of_day = minetest.get_timeofday()
|
self.time_of_day = minetest.get_timeofday()
|
||||||
|
|
||||||
-- halt mob if standing inside ignore node
|
-- halt mob if standing inside ignore node
|
||||||
@ -3153,9 +3165,9 @@ function mob_class:mob_staticdata()
|
|||||||
make_footstep_sound = self.make_footstep_sound,
|
make_footstep_sound = self.make_footstep_sound,
|
||||||
stepheight = self.stepheight,
|
stepheight = self.stepheight,
|
||||||
glow = self.glow,
|
glow = self.glow,
|
||||||
nametag = self.nametag,
|
-- nametag = self.nametag,
|
||||||
damage_texture_modifier = self.damage_texture_modifier,
|
damage_texture_modifier = self.damage_texture_modifier,
|
||||||
infotext = self.infotext
|
-- infotext = self.infotext
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -3295,13 +3307,8 @@ function mob_class:mob_activate(staticdata, def, dtime)
|
|||||||
self.standing_in = "air"
|
self.standing_in = "air"
|
||||||
self.standing_on = "air"
|
self.standing_on = "air"
|
||||||
|
|
||||||
-- check for existing nametag
|
|
||||||
self.nametag = self.nametag or def.nametag
|
|
||||||
|
|
||||||
-- set anything changed above
|
-- set anything changed above
|
||||||
-- self.object:set_properties(self)
|
|
||||||
self:set_yaw((random(0, 360) - 180) / 180 * pi, 6)
|
self:set_yaw((random(0, 360) - 180) / 180 * pi, 6)
|
||||||
self:update_tag()
|
|
||||||
self:set_animation("stand")
|
self:set_animation("stand")
|
||||||
|
|
||||||
-- apply any texture mods
|
-- apply any texture mods
|
||||||
@ -3913,10 +3920,7 @@ function mobs:add_mob(pos, def)
|
|||||||
def.nametag = def.nametag:sub(1, 64)
|
def.nametag = def.nametag:sub(1, 64)
|
||||||
end
|
end
|
||||||
|
|
||||||
mob:set_properties({nametag = def.nametag})
|
ent:update_tag(def.nametag)
|
||||||
ent.nametag = def.nametag
|
|
||||||
|
|
||||||
ent:update_tag()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return ent
|
return ent
|
||||||
@ -4764,7 +4768,7 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
|
|||||||
mob_sta[name] = item
|
mob_sta[name] = item
|
||||||
|
|
||||||
local prop = self.object:get_properties()
|
local prop = self.object:get_properties()
|
||||||
local tag = prop.nametag or ""
|
local tag = self._nametag or ""
|
||||||
local esc = minetest.formspec_escape
|
local esc = minetest.formspec_escape
|
||||||
|
|
||||||
minetest.show_formspec(name, "mobs_nametag", "size[8,4]"
|
minetest.show_formspec(name, "mobs_nametag", "size[8,4]"
|
||||||
@ -4819,9 +4823,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- update nametag
|
-- update nametag
|
||||||
mob_obj[name].object:set_properties({nametag = fields.name})
|
mob_obj[name]:update_tag(fields.name)
|
||||||
mob_obj[name].nametag = fields.name
|
|
||||||
mob_obj[name]:update_tag()
|
|
||||||
|
|
||||||
-- if not in creative then take item
|
-- if not in creative then take item
|
||||||
if not mobs.is_creative(name) then
|
if not mobs.is_creative(name) then
|
||||||
|
Loading…
Reference in New Issue
Block a user