use self.backup_properties instead of self.initial_properties

This commit is contained in:
tenplus1 2023-10-05 11:54:44 +01:00
parent 55bdc4c0a4
commit c173345135
1 changed files with 7 additions and 5 deletions

12
api.lua
View File

@ -11,7 +11,7 @@ local use_mc2 = minetest.get_modpath("mcl_core")
-- Global -- Global
mobs = { mobs = {
mod = "redo", mod = "redo",
version = "20231004", version = "20231005",
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"]
@ -3137,10 +3137,11 @@ function mob_class:mob_staticdata()
self.serialized_cmi_components = cmi.serialize_components(self._cmi_components) self.serialized_cmi_components = cmi.serialize_components(self._cmi_components)
end end
-- move existing variables to new initial_properties table for future compatibility -- move existing variables to new table for future compatibility
if not self.initial_properties then -- using self.initial_properties lost some variables when backing up?!?
if not self.backup_properties then
self.initial_properties = { self.backup_properties = {
hp_max = self.hp_max, hp_max = self.hp_max,
physical = self.physical, physical = self.physical,
collisionbox = self.collisionbox, collisionbox = self.collisionbox,
@ -4706,7 +4707,7 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
if self.child == true then if self.child == true then
-- deduct 10% of the time to adulthood -- deduct 10% of the time to adulthood
self.hornytimer = math.floor(self.hornytimer + ( self.hornytimer = floor(self.hornytimer + (
(CHILD_GROW_TIME - self.hornytimer) * 0.1)) (CHILD_GROW_TIME - self.hornytimer) * 0.1))
--print ("====", self.hornytimer) --print ("====", self.hornytimer)
return true return true
@ -4728,6 +4729,7 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
if tame then if tame then
if self.tamed == false then if self.tamed == false then
minetest.chat_send_player(clicker:get_player_name(), minetest.chat_send_player(clicker:get_player_name(),
S("@1 has been tamed!", S("@1 has been tamed!",
self.name:split(":")[2])) self.name:split(":")[2]))