tweak child textures when growing

This commit is contained in:
tenplus1 2023-05-27 19:29:01 +01:00
parent b42f7c63c8
commit cc71ea4e95
1 changed files with 46 additions and 33 deletions

15
api.lua
View File

@ -25,7 +25,7 @@ local use_cmi = minetest.global_exists("cmi")
mobs = { mobs = {
mod = "redo", mod = "redo",
version = "20230526", version = "20230527",
intllib = S, intllib = S,
invis = minetest.global_exists("invisibility") and invisibility or {} invis = minetest.global_exists("invisibility") and invisibility or {}
} }
@ -1370,6 +1370,12 @@ function mob_class:breed()
self.child = false self.child = false
self.hornytimer = 0 self.hornytimer = 0
-- replace child texture with adult one
if self.mommy_tex then
self.base_texture = self.mommy_tex
self.mommy_tex = nil
end
self.object:set_properties({ self.object:set_properties({
textures = self.base_texture, textures = self.base_texture,
mesh = self.base_mesh, mesh = self.base_mesh,
@ -1504,9 +1510,13 @@ function mob_class:breed()
local ent2 = mob:get_luaentity() local ent2 = mob:get_luaentity()
local textures = self.base_texture local textures = self.base_texture
-- make sure baby is actually there
if ent2 then
-- using specific child texture (if found) -- using specific child texture (if found)
if self.child_texture then if self.child_texture then
textures = self.child_texture[1] textures = self.child_texture[1]
ent2.mommy_tex = self.base_texture
end end
-- and resize to half height -- and resize to half height
@ -1533,10 +1543,13 @@ function mob_class:breed()
self.base_selbox[6] * .5 self.base_selbox[6] * .5
} }
}) })
-- tamed and owned by parents' owner -- tamed and owned by parents' owner
ent2.child = true ent2.child = true
ent2.tamed = true ent2.tamed = true
ent2.owner = self.owner ent2.owner = self.owner
ent2.base_texture = textures
end
end, self, ent) end, self, ent)
break break